libmoost
/home/mhx/git/github/libmoost/include/moost/mq/stomp_client.h
Go to the documentation of this file.
00001 /* vim:set ts=3 sw=3 sts=3 et: */
00028 #ifndef MOOST_MQ_STOMP_CLIENT_H_
00029 #define MOOST_MQ_STOMP_CLIENT_H_
00030 
00031 #include <string>
00032 
00033 #include <boost/date_time/posix_time/posix_time.hpp>
00034 #include <boost/system/error_code.hpp>
00035 #include <boost/shared_ptr.hpp>
00036 #include <boost/function.hpp>
00037 #include <boost/cstdint.hpp>
00038 
00039 namespace moost { namespace mq {
00040 
00046 class stomp_client
00047 {
00048 public:
00052    struct ack
00053    {
00054       enum type
00055       {
00056          automatic,
00057          client
00058       };
00059    };
00060 
00075    stomp_client(size_t consumer_pool_size = 1,
00076                 const boost::posix_time::time_duration& keepalive_interval = boost::posix_time::seconds(30),
00077                 const boost::posix_time::time_duration& reconnect_interval = boost::posix_time::seconds(1));
00078 
00082    ~stomp_client();
00083 
00093    void connect(const std::string& hostname, int port,
00094                 boost::function<void (const boost::system::error_code&, const std::string&)> error_cb);
00095 
00099    void disconnect();
00100 
00114    void subscribe(const std::string& topic, boost::function<void (const std::string&)> message_cb, ack::type ack_type = ack::automatic,
00115                   const boost::posix_time::time_duration& max_msg_interval = boost::posix_time::pos_infin);
00116 
00122    void unsubscribe(const std::string& topic);
00123 
00131    void send(const std::string& topic, const std::string& message);
00132 
00142    bool is_connected() const;
00143 
00152    bool is_online() const;
00153 
00159    uint64_t get_num_processed() const;
00160 
00166    size_t get_num_pending() const;
00167 
00168 private:
00169    class impl;
00170    boost::shared_ptr<impl> m_impl;
00171 };
00172 
00173 }}
00174 
00175 #endif