libmoost
|
#include <stomp_client.h>
Classes | |
struct | ack |
class | impl |
Public Member Functions | |
stomp_client (size_t consumer_pool_size=1, const boost::posix_time::time_duration &keepalive_interval=boost::posix_time::seconds(30), const boost::posix_time::time_duration &reconnect_interval=boost::posix_time::seconds(1)) | |
~stomp_client () | |
void | connect (const std::string &hostname, int port, boost::function< void(const boost::system::error_code &, const std::string &)> error_cb) |
void | disconnect () |
void | subscribe (const std::string &topic, boost::function< void(const std::string &)> message_cb, ack::type ack_type=ack::automatic, const boost::posix_time::time_duration &max_msg_interval=boost::posix_time::pos_infin) |
void | unsubscribe (const std::string &topic) |
void | send (const std::string &topic, const std::string &message) |
bool | is_connected () const |
bool | is_online () const |
uint64_t | get_num_processed () const |
size_t | get_num_pending () const |
Private Attributes | |
boost::shared_ptr< impl > | m_impl |
STOMP client implementation
This class implements a multi-stream, multi-thread STOMP client.
Definition at line 46 of file stomp_client.h.
moost::mq::stomp_client::stomp_client | ( | size_t | consumer_pool_size = 1 , |
const boost::posix_time::time_duration & | keepalive_interval = boost::posix_time::seconds(30) , |
||
const boost::posix_time::time_duration & | reconnect_interval = boost::posix_time::seconds(1) |
||
) |
Create a new client
consumer_pool_size | The number of threads from which messages shall be dispatched. This can be useful if the actual message processing is quite CPU intensive. |
keepalive_interval | The interval in which keepalive packets will be sent to the server. |
reconnect_interval | The interval in which reconnection attempts will be made after a failed connection attempt. |
Definition at line 33 of file stomp_client.cpp.
Destroy a client
Definition at line 40 of file stomp_client.cpp.
void moost::mq::stomp_client::connect | ( | const std::string & | hostname, |
int | port, | ||
boost::function< void(const boost::system::error_code &, const std::string &)> | error_cb | ||
) |
Connect to queue server
hostname | Host name of the queue server. |
port | Port number of the queue server. |
error_cb | Callback for asynchronous errors. |
Definition at line 51 of file stomp_client.cpp.
void moost::mq::stomp_client::disconnect | ( | ) |
Disconnect from queue server
Definition at line 56 of file stomp_client.cpp.
size_t moost::mq::stomp_client::get_num_pending | ( | ) | const |
Get number of messages received but currently pending
Definition at line 95 of file stomp_client.cpp.
uint64_t moost::mq::stomp_client::get_num_processed | ( | ) | const |
Get number of messages processed by this object
Definition at line 90 of file stomp_client.cpp.
bool moost::mq::stomp_client::is_connected | ( | ) | const |
Check if the client object is connected to the server
Note that "being connected" is a state of the object. The object may be connected even though the server is offline, in which case the object will attempt to periodically reconnect to the server.
Definition at line 80 of file stomp_client.cpp.
bool moost::mq::stomp_client::is_online | ( | ) | const |
Check if the connected server is online
Use this method to actually check if the connection between the client and server is healthy.
Definition at line 85 of file stomp_client.cpp.
void moost::mq::stomp_client::send | ( | const std::string & | topic, |
const std::string & | message | ||
) |
Send message to the queue server
topic | Topic (destination) of the message. |
message | Message content. |
Definition at line 75 of file stomp_client.cpp.
void moost::mq::stomp_client::subscribe | ( | const std::string & | topic, |
boost::function< void(const std::string &)> | message_cb, | ||
ack::type | ack_type = ack::automatic , |
||
const boost::posix_time::time_duration & | max_msg_interval = boost::posix_time::pos_infin |
||
) |
Subscribe to a topic
topic | Topic (destination) to subscribe to. |
message_cb | Callback for received messages for this topic. |
ack_type | Which acknowledgement protocol to use. |
max_msg_interval | The maximum expected interval between any two messages. If this interval is exceeded, the client will initiate a reconnect to the server. |
Definition at line 64 of file stomp_client.cpp.
void moost::mq::stomp_client::unsubscribe | ( | const std::string & | topic | ) |
Unsubscribe from a topic
topic | Topic (destination) to unsubscribe from. |
Definition at line 70 of file stomp_client.cpp.
boost::shared_ptr<impl> moost::mq::stomp_client::m_impl [private] |
Definition at line 169 of file stomp_client.h.