~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/rabbitmq/rabbitmq_handler.h

  • Committer: Andrew Hutchings
  • Date: 2010-12-06 19:36:53 UTC
  • mfrom: (1976 staging)
  • mto: This revision was merged to the branch mainline in revision 1991.
  • Revision ID: andrew@linuxjedi.co.uk-20101206193653-l85vryv18jb0yxx8
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <string>
30
30
#include <amqp.h>
31
31
#include <amqp_framing.h>
 
32
#include <netinet/in.h>
 
33
 
 
34
namespace drizzle_plugin
 
35
{
32
36
 
33
37
/**
34
38
 * exception thrown by the rabbitmq handler
35
39
 *
36
40
 */
37
 
class rabbitmq_handler_exception: public std::exception
 
41
class rabbitmq_handler_exception : public std::exception
38
42
{
39
43
private:
40
44
  const char* message;
58
62
  amqp_connection_state_t rabbitmqConnection; 
59
63
  int sockfd; ///< the socket file desc to the rabbitmq server, 
60
64
              ///< need this to be able to close() it.
61
 
  const char* hostname;
62
 
  const int port;
63
 
  const char* username;
64
 
  const char* password;
65
 
  const char* virtualhost;
 
65
  const std::string &hostname;
 
66
  const in_port_t port;
 
67
  const std::string &username;
 
68
  const std::string &password;
 
69
  const std::string &virtualhost;
66
70
public:
67
71
  /**
68
72
   * @brief
80
84
   * @param[in] virtualhost the rabbitmq virtual host.
81
85
   * @throw exception if we cannot connect to rabbitmq server
82
86
   */
83
 
  RabbitMQHandler(const char* hostname, 
84
 
                  const int port, 
85
 
                  const char* username, 
86
 
                  const char* password, 
87
 
                  const char* virtualhost) throw(rabbitmq_handler_exception);
 
87
  RabbitMQHandler(const std::string &hostname, 
 
88
                  const in_port_t port, 
 
89
                  const std::string &username, 
 
90
                  const std::string &password, 
 
91
                  const std::string &virtualhost)
 
92
    throw(rabbitmq_handler_exception);
 
93
 
88
94
  ~RabbitMQHandler();
89
95
 
90
96
  /**
100
106
   * @param[in] routingKey the routing key to use
101
107
   * @throw exception if there is a problem publishing
102
108
   */
103
 
  void publish(const uint8_t *message, 
104
 
               const int length, 
105
 
               const char* exchangeName, 
106
 
               const char* routingKey) throw(rabbitmq_handler_exception);
107
 
 
108
 
 
109
 
 private:
 
109
  void publish(void *message, 
 
110
               const int length, 
 
111
               const std::string &exchangeName, 
 
112
               const std::string &routingKey)
 
113
    throw(rabbitmq_handler_exception);
 
114
 
 
115
 
 
116
private:
110
117
  /**
111
118
   * @brief
112
119
   *   Handles errors produced by librabbitmq
122
129
  void handleAMQPError(amqp_rpc_reply_t x, std::string context) throw(rabbitmq_handler_exception);
123
130
};
124
131
 
 
132
} /* namespace drizzle_plugin */
 
133
 
125
134
#endif /* PLUGIN_RABBITMQ_RABBITMQ_HANDLER_H */