libmoost
moost::mq::stomp_client Class Reference

#include <stomp_client.h>

List of all members.

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< implm_impl

Detailed Description

STOMP client implementation

This class implements a multi-stream, multi-thread STOMP client.

Definition at line 46 of file stomp_client.h.


Constructor & Destructor Documentation

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

Parameters:
consumer_pool_sizeThe number of threads from which messages shall be dispatched. This can be useful if the actual message processing is quite CPU intensive.
keepalive_intervalThe interval in which keepalive packets will be sent to the server.
reconnect_intervalThe 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.

Here is the call graph for this function:


Member Function Documentation

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

Parameters:
hostnameHost name of the queue server.
portPort number of the queue server.
error_cbCallback for asynchronous errors.

Definition at line 51 of file stomp_client.cpp.

Here is the caller graph for this function:

Disconnect from queue server

Definition at line 56 of file stomp_client.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Get number of messages received but currently pending

Returns:
Number of pending messages.

Definition at line 95 of file stomp_client.cpp.

Get number of messages processed by this object

Returns:
Number of processed messages.

Definition at line 90 of file stomp_client.cpp.

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.

Returns:
Boolean indicating whether the client object is connected.

Definition at line 80 of file stomp_client.cpp.

Here is the caller graph for this function:

Check if the connected server is online

Use this method to actually check if the connection between the client and server is healthy.

Returns:
Boolean indicating whether the server is online.

Definition at line 85 of file stomp_client.cpp.

Here is the caller graph for this function:

void moost::mq::stomp_client::send ( const std::string &  topic,
const std::string &  message 
)

Send message to the queue server

Parameters:
topicTopic (destination) of the message.
messageMessage 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

Parameters:
topicTopic (destination) to subscribe to.
message_cbCallback for received messages for this topic.
ack_typeWhich acknowledgement protocol to use.
max_msg_intervalThe 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.

Here is the caller graph for this function:

void moost::mq::stomp_client::unsubscribe ( const std::string &  topic)

Unsubscribe from a topic

Parameters:
topicTopic (destination) to unsubscribe from.

Definition at line 70 of file stomp_client.cpp.


Member Data Documentation

boost::shared_ptr<impl> moost::mq::stomp_client::m_impl [private]

Definition at line 169 of file stomp_client.h.


The documentation for this class was generated from the following files: