Drizzled Public API Documentation

drizzle_plugin::rabbitmq::RabbitMQHandler Class Reference

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)
 
void connect () throw (rabbitmq_handler_exception)
 

Public Attributes

bool rabbitmq_connection_established
 

Private Member Functions

void handleAMQPError (amqp_rpc_reply_t x, std::string context) throw (rabbitmq_handler_exception)
 Handles errors produced by librabbitmq. More...
 

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
 

Detailed Description

wrapper around librabbitmq, hides error handling and reconnections etc TODO: add reconnection handling

Definition at line 58 of file rabbitmq_handler.h.

Constructor & Destructor Documentation

drizzle_plugin::rabbitmq::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.

Parameters
[in]hostnamethe host to connect to.
[in]portthe port.
[in]usernamethe username to use when logging in.
[in]passwordthe password to use.
[in]virtualhostthe rabbitmq virtual host.
Exceptions
exceptionif we cannot connect to rabbitmq server

Definition at line 41 of file rabbitmq_handler.cc.

Member Function Documentation

void drizzle_plugin::rabbitmq::RabbitMQHandler::handleAMQPError ( amqp_rpc_reply_t  x,
std::string  context 
)
throw (rabbitmq_handler_exception
)
private

Handles errors produced by librabbitmq.

If an error occurs, an error string is thrown.

Parameters
[in]xthe response from librabbitmq
[in]contextthe context the call occured, simply appended to the error message.
Exceptions
exceptionwith the message unless the command was successful

Definition at line 155 of file rabbitmq_handler.cc.

void drizzle_plugin::rabbitmq::RabbitMQHandler::publish ( void *  message,
const int  length 
)
throw (rabbitmq_handler_exception
)

Publishes the message to the server.

publishes the given message

Parameters
[in]messagethe message to send
[in]lengththe length of the message
Exceptions
exceptionif there is a problem publishing

Definition at line 69 of file rabbitmq_handler.cc.

Referenced by drizzle_plugin::rabbitmq::RabbitMQLog::apply().

Member Data Documentation

int drizzle_plugin::rabbitmq::RabbitMQHandler::sockfd
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.


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