userver: urabbitmq::Client Class Reference
Loading...
Searching...
No Matches
urabbitmq::Client Class Reference

#include <userver/urabbitmq/client.hpp>

Detailed Description

Interface for communicating with a RabbitMQ cluster.

Usually retrieved from components::RabbitMQ component.

Definition at line 28 of file client.hpp.

+ Inheritance diagram for urabbitmq::Client:

Public Member Functions

 ~Client ()
 Client destructor.
 
void DeclareExchange (const Exchange &exchange, Exchange::Type type, utils::Flags< Exchange::Flags > flags, engine::Deadline deadline) override
 Declare an exchange.
 
void DeclareExchange (const Exchange &exchange, Exchange::Type type, engine::Deadline deadline) override
 overload of DeclareExchange
 
void DeclareExchange (const Exchange &exchange, engine::Deadline deadline) override
 overload of DeclareExchange
 
void DeclareQueue (const Queue &queue, utils::Flags< Queue::Flags > flags, engine::Deadline deadline) override
 Declare a queue.
 
void DeclareQueue (const Queue &queue, engine::Deadline deadline) override
 overload of DeclareQueue
 
void BindQueue (const Exchange &exchange, const Queue &queue, const std::string &routing_key, engine::Deadline deadline) override
 Bind a queue to an exchange.
 
void RemoveExchange (const Exchange &exchange, engine::Deadline deadline) override
 Remove an exchange.
 
void RemoveQueue (const Queue &queue, engine::Deadline deadline) override
 Remove a queue.
 
AdminChannel GetAdminChannel (engine::Deadline deadline)
 Get an administrative interface for the broker.
 
void Publish (const Exchange &exchange, const std::string &routing_key, const std::string &message, MessageType type, engine::Deadline deadline) override
 Publish a message to an exchange.
 
void Publish (const Exchange &exchange, const std::string &routing_key, const std::string &message, engine::Deadline deadline) override
 overload of Publish
 
std::string Get (const Queue &queue, utils::Flags< Queue::Flags > flags, engine::Deadline deadline) override
 Gets a single message.
 
Channel GetChannel (engine::Deadline deadline)
 Get a publisher interface for the broker.
 
void PublishReliable (const Exchange &exchange, const std::string &routing_key, const std::string &message, MessageType type, engine::Deadline deadline) override
 Publish a message to an exchange and await confirmation from the broker.
 
void PublishReliable (const Exchange &exchange, const std::string &routing_key, const std::string &message, engine::Deadline deadline) override
 overload of PublishReliable
 
ReliableChannel GetReliableChannel (engine::Deadline deadline)
 Get a reliable publisher interface for the broker (publisher-confirms)
 
void WriteStatistics (utils::statistics::Writer &writer) const
 Write cluster statistics.
 

Static Public Member Functions

static std::shared_ptr< ClientCreate (clients::dns::Resolver &resolver, const ClientSettings &settings)
 

Protected Member Functions

 Client (clients::dns::Resolver &resolver, const ClientSettings &settings)
 

Member Function Documentation

◆ BindQueue()

void urabbitmq::Client::BindQueue ( const Exchange & exchange,
const Queue & queue,
const std::string & routing_key,
engine::Deadline deadline )
overridevirtual

Bind a queue to an exchange.

Parameters
exchangethe source exchange
queuethe target queue
routing_keythe routing key
deadlineexecution deadline

Implements urabbitmq::IAdminInterface.

◆ Create()

static std::shared_ptr< Client > urabbitmq::Client::Create ( clients::dns::Resolver & resolver,
const ClientSettings & settings )
static

Client factory function

Parameters
resolverasynchronous DNS resolver
settingsclient settings

◆ DeclareExchange() [1/3]

void urabbitmq::Client::DeclareExchange ( const Exchange & exchange,
engine::Deadline deadline )
inlineoverridevirtual

overload of DeclareExchange

Implements urabbitmq::IAdminInterface.

Definition at line 50 of file client.hpp.

◆ DeclareExchange() [2/3]

void urabbitmq::Client::DeclareExchange ( const Exchange & exchange,
Exchange::Type type,
engine::Deadline deadline )
inlineoverridevirtual

overload of DeclareExchange

Implements urabbitmq::IAdminInterface.

Definition at line 45 of file client.hpp.

◆ DeclareExchange() [3/3]

void urabbitmq::Client::DeclareExchange ( const Exchange & exchange,
Exchange::Type type,
utils::Flags< Exchange::Flags > flags,
engine::Deadline deadline )
overridevirtual

Declare an exchange.

Parameters
exchangename of the exchange
typeexchange type
flagsexchange flags
deadlineexecution deadline

Implements urabbitmq::IAdminInterface.

◆ DeclareQueue() [1/2]

void urabbitmq::Client::DeclareQueue ( const Queue & queue,
engine::Deadline deadline )
inlineoverridevirtual

overload of DeclareQueue

Implements urabbitmq::IAdminInterface.

Definition at line 58 of file client.hpp.

◆ DeclareQueue() [2/2]

void urabbitmq::Client::DeclareQueue ( const Queue & queue,
utils::Flags< Queue::Flags > flags,
engine::Deadline deadline )
overridevirtual

Declare a queue.

Parameters
queuename of the queue
flagsqueue flags
deadlineexecution deadline

Implements urabbitmq::IAdminInterface.

◆ Get()

std::string urabbitmq::Client::Get ( const Queue & queue,
utils::Flags< Queue::Flags > flags,
engine::Deadline deadline )
overridevirtual

Gets a single message.

You should to set kNoAck flag in order for server to implicitly acknowledge gathered message. By default the gathered message has to be explicitly acknowledged or rejected, however there's no functionality for that yet, so the flag is basically mandatory. This API is a subject to change.

Note
This method uses a polling model for retrieving a message, which is comparatively expensive and might lead to a connection reset in case of a timeout. This method could come in handy in some cases, but in general we recommend to set up a Consumer instead.
Parameters
queuename of the queue
flagsqueue flags
deadlineexecution deadline

Implements urabbitmq::IChannelInterface.

◆ GetAdminChannel()

AdminChannel urabbitmq::Client::GetAdminChannel ( engine::Deadline deadline)

Get an administrative interface for the broker.

Parameters
deadlinedeadline for connection acquisition from the pool

◆ GetChannel()

Channel urabbitmq::Client::GetChannel ( engine::Deadline deadline)

Get a publisher interface for the broker.

Parameters
deadlinedeadline for connection acquisition from the pool

◆ GetReliableChannel()

ReliableChannel urabbitmq::Client::GetReliableChannel ( engine::Deadline deadline)

Get a reliable publisher interface for the broker (publisher-confirms)

Parameters
deadlinedeadline for connection acquisition from the pool

◆ Publish() [1/2]

void urabbitmq::Client::Publish ( const Exchange & exchange,
const std::string & routing_key,
const std::string & message,
engine::Deadline deadline )
inlineoverridevirtual

overload of Publish

Implements urabbitmq::IChannelInterface.

Definition at line 80 of file client.hpp.

◆ Publish() [2/2]

void urabbitmq::Client::Publish ( const Exchange & exchange,
const std::string & routing_key,
const std::string & message,
MessageType type,
engine::Deadline deadline )
overridevirtual

Publish a message to an exchange.

You have to supply the name of the exchange and a routing key. RabbitMQ will then try to send the message to one or more queues. By default unroutable messages are silently discarded

Parameters
exchangethe exchange to publish to
routing_keythe routing key
messagethe message to send
deadlineexecution deadline
Note
This method is fire and forget (no delivery guarantees), use PublishReliable for delivery guarantees.

Implements urabbitmq::IChannelInterface.

◆ PublishReliable() [1/2]

void urabbitmq::Client::PublishReliable ( const Exchange & exchange,
const std::string & routing_key,
const std::string & message,
engine::Deadline deadline )
inlineoverridevirtual

overload of PublishReliable

Implements urabbitmq::IReliableChannelInterface.

Definition at line 97 of file client.hpp.

◆ PublishReliable() [2/2]

void urabbitmq::Client::PublishReliable ( const Exchange & exchange,
const std::string & routing_key,
const std::string & message,
MessageType type,
engine::Deadline deadline )
overridevirtual

Publish a message to an exchange and await confirmation from the broker.

You have to supply the name of the exchange and a routing key. RabbitMQ will then try to send the message to one or more queues. By default unroutable messages are silently discarded

Parameters
exchangethe exchange to publish to
routing_keythe routing key
messagethe message to send
deadlineexecution deadline

Implements urabbitmq::IReliableChannelInterface.

◆ RemoveExchange()

void urabbitmq::Client::RemoveExchange ( const Exchange & exchange,
engine::Deadline deadline )
overridevirtual

Remove an exchange.

Parameters
exchangename of the exchange to remove
deadlineexecution deadline

Implements urabbitmq::IAdminInterface.

◆ RemoveQueue()

void urabbitmq::Client::RemoveQueue ( const Queue & queue,
engine::Deadline deadline )
overridevirtual

Remove a queue.

Parameters
queuename of the queue to remove
deadlineexecution deadline

Implements urabbitmq::IAdminInterface.

Friends And Related Symbol Documentation

◆ ConsumerBase

friend class ConsumerBase
friend

Definition at line 117 of file client.hpp.


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