wrapper around librabbitmq, hides error handling and reconnections etc TODO: add reconnection handling More...
#include <rabbitmq_handler.h>
Public Member Functions | |
RabbitMQHandler (const std::string &hostname, const in_port_t port, const std::string &username, const std::string &password, const std::string &virtualhost, const std::string &exchange, const std::string &routingKey) throw (rabbitmq_handler_exception) | |
Constructs a new RabbitMQHandler, purpose is to hide away the error handling, reconnections etc. More... | |
void | publish (void *message, const int length) throw (rabbitmq_handler_exception) |
Publishes the message to the server. More... | |
void | reconnect () throw (rabbitmq_handler_exception) |
void | disconnect () throw (rabbitmq_handler_exception) |
Private Member Functions | |
void | handleAMQPError (amqp_rpc_reply_t x, std::string context) throw (rabbitmq_handler_exception) |
Handles errors produced by librabbitmq. More... | |
void | connect () throw (rabbitmq_handler_exception) |
Private Attributes | |
amqp_connection_state_t | rabbitmqConnection |
int | sockfd |
const std::string & | hostname |
const in_port_t | port |
const std::string & | username |
const std::string & | password |
const std::string & | virtualhost |
const std::string & | exchange |
const std::string & | routingKey |
pthread_mutex_t | publishLock |
wrapper around librabbitmq, hides error handling and reconnections etc TODO: add reconnection handling
Definition at line 58 of file rabbitmq_handler.h.
drizzle_plugin::RabbitMQHandler::RabbitMQHandler | ( | const std::string & | hostname, |
const in_port_t | port, | ||
const std::string & | username, | ||
const std::string & | password, | ||
const std::string & | virtualhost, | ||
const std::string & | exchange, | ||
const std::string & | routingKey | ||
) | |||
throw | ( | rabbitmq_handler_exception | |
) |
Constructs a new RabbitMQHandler, purpose is to hide away the error handling, reconnections etc.
Connects to the given rabbitmq server on the virtualhost with the given username/password.
[in] | hostname | the host to connect to. |
[in] | port | the port. |
[in] | username | the username to use when logging in. |
[in] | password | the password to use. |
[in] | virtualhost | the rabbitmq virtual host. |
exception | if we cannot connect to rabbitmq server |
Definition at line 39 of file rabbitmq_handler.cc.
|
private |
Handles errors produced by librabbitmq.
If an error occurs, an error string is thrown.
[in] | x | the response from librabbitmq |
[in] | context | the context the call occured, simply appended to the error message. |
exception | with the message unless the command was successful |
Definition at line 139 of file rabbitmq_handler.cc.
void drizzle_plugin::RabbitMQHandler::publish | ( | void * | message, |
const int | length | ||
) | |||
throw | ( | rabbitmq_handler_exception | |
) |
Publishes the message to the server.
publishes the given message
[in] | message | the message to send |
[in] | length | the length of the message |
exception | if there is a problem publishing |
Definition at line 66 of file rabbitmq_handler.cc.
Referenced by drizzle_plugin::RabbitMQLog::apply().
|
private |
the socket file desc to the rabbitmq server, need this to be able to close() it.
Definition at line 62 of file rabbitmq_handler.h.