~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/rabbitmq/rabbitmq_handler.h

Merge Joe, plus I updated the tests.

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
 
{
36
32
 
37
33
/**
38
34
 * exception thrown by the rabbitmq handler
39
35
 *
40
36
 */
41
 
class rabbitmq_handler_exception : public std::exception
 
37
class rabbitmq_handler_exception: public std::exception
42
38
{
43
39
private:
44
40
  const char* message;
62
58
  amqp_connection_state_t rabbitmqConnection; 
63
59
  int sockfd; ///< the socket file desc to the rabbitmq server, 
64
60
              ///< need this to be able to close() it.
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;
 
61
  const char* hostname;
 
62
  const int port;
 
63
  const char* username;
 
64
  const char* password;
 
65
  const char* virtualhost;
70
66
public:
71
67
  /**
72
68
   * @brief
84
80
   * @param[in] virtualhost the rabbitmq virtual host.
85
81
   * @throw exception if we cannot connect to rabbitmq server
86
82
   */
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
 
 
 
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);
94
88
  ~RabbitMQHandler();
95
89
 
96
90
  /**
106
100
   * @param[in] routingKey the routing key to use
107
101
   * @throw exception if there is a problem publishing
108
102
   */
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:
 
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:
117
110
  /**
118
111
   * @brief
119
112
   *   Handles errors produced by librabbitmq
129
122
  void handleAMQPError(amqp_rpc_reply_t x, std::string context) throw(rabbitmq_handler_exception);
130
123
};
131
124
 
132
 
} /* namespace drizzle_plugin */
133
 
 
134
125
#endif /* PLUGIN_RABBITMQ_RABBITMQ_HANDLER_H */