drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzle_plugin::rabbitmq::RabbitMQHandler Class Reference

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

#include <rabbitmq_handler.h>

Collaboration diagram for drizzle_plugin::rabbitmq::RabbitMQHandler:
[legend]

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)
 Constructs a new RabbitMQHandler, purpose is to hide away the error handling, reconnections etc.
void publish (void *message, const int length)
 Publishes the message to the server.
void reconnect ()
void disconnect ()
void connect ()

Public Attributes

bool rabbitmq_connection_established

Private Member Functions

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

Private Attributes

amqp_connection_state_t rabbitmqConnection
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 59 of file rabbitmq_handler.h.

Constructor & Destructor Documentation

◆ RabbitMQHandler()

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 )

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 42 of file rabbitmq_handler.cc.

◆ ~RabbitMQHandler()

drizzle_plugin::rabbitmq::RabbitMQHandler::~RabbitMQHandler ( )

Definition at line 63 of file rabbitmq_handler.cc.

Member Function Documentation

◆ connect()

void drizzle_plugin::rabbitmq::RabbitMQHandler::connect ( )

Definition at line 119 of file rabbitmq_handler.cc.

◆ disconnect()

void drizzle_plugin::rabbitmq::RabbitMQHandler::disconnect ( )

Definition at line 103 of file rabbitmq_handler.cc.

◆ handleAMQPError()

void drizzle_plugin::rabbitmq::RabbitMQHandler::handleAMQPError ( amqp_rpc_reply_t x,
std::string context )
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 157 of file rabbitmq_handler.cc.

◆ publish()

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

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.

◆ reconnect()

void drizzle_plugin::rabbitmq::RabbitMQHandler::reconnect ( )

Definition at line 97 of file rabbitmq_handler.cc.

Member Data Documentation

◆ exchange

const std::string& drizzle_plugin::rabbitmq::RabbitMQHandler::exchange
private

Definition at line 68 of file rabbitmq_handler.h.

◆ hostname

const std::string& drizzle_plugin::rabbitmq::RabbitMQHandler::hostname
private

Definition at line 63 of file rabbitmq_handler.h.

◆ password

const std::string& drizzle_plugin::rabbitmq::RabbitMQHandler::password
private

Definition at line 66 of file rabbitmq_handler.h.

◆ port

const in_port_t drizzle_plugin::rabbitmq::RabbitMQHandler::port
private

Definition at line 64 of file rabbitmq_handler.h.

◆ publishLock

pthread_mutex_t drizzle_plugin::rabbitmq::RabbitMQHandler::publishLock
private

Definition at line 70 of file rabbitmq_handler.h.

◆ rabbitmq_connection_established

bool drizzle_plugin::rabbitmq::RabbitMQHandler::rabbitmq_connection_established

Definition at line 72 of file rabbitmq_handler.h.

◆ rabbitmqConnection

amqp_connection_state_t drizzle_plugin::rabbitmq::RabbitMQHandler::rabbitmqConnection
private

Definition at line 62 of file rabbitmq_handler.h.

◆ routingKey

const std::string& drizzle_plugin::rabbitmq::RabbitMQHandler::routingKey
private

Definition at line 69 of file rabbitmq_handler.h.

◆ username

const std::string& drizzle_plugin::rabbitmq::RabbitMQHandler::username
private

Definition at line 65 of file rabbitmq_handler.h.

◆ virtualhost

const std::string& drizzle_plugin::rabbitmq::RabbitMQHandler::virtualhost
private

Definition at line 67 of file rabbitmq_handler.h.


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