userver: urabbitmq::Channel Class Reference
Loading...
Searching...
No Matches
urabbitmq::Channel Class Referencefinal

#include <userver/urabbitmq/channel.hpp>

Detailed Description

Publisher interface for the broker. You may use this class to publish your messages.

You may as well use Client itself instead, this class just gives you some order guaranties.

You are not expected to store this class for a long time, because it takes a connection from the underlying connections pool.

Usually retrieved from Client.

Definition at line 28 of file channel.hpp.

+ Inheritance diagram for urabbitmq::Channel:

Public Member Functions

 Channel (ConnectionPtr &&channel)
 
 Channel (Channel &&other) noexcept
 
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.
 

Member Function Documentation

◆ Get()

std::string urabbitmq::Channel::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.

◆ Publish() [1/2]

void urabbitmq::Channel::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 43 of file channel.hpp.

◆ Publish() [2/2]

void urabbitmq::Channel::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.


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