RMQ - RabbitMQ C++ Library
Public Member Functions | List of all members
BloombergLP::rmqa::Producer Class Reference

Provide a RabbitMQ Producer API for publishing to a specific Exchange. More...

#include <rmqa_producer.h>

Public Member Functions

 Producer (bslma::ManagedPtr< rmqp::Producer > &impl)
 
rmqp::Producer::SendStatus send (const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
void addTransformer (const bsl::shared_ptr< rmqp::MessageTransformer > &transformer)
 
rmqp::Producer::SendStatus send (const rmqt::Message &message, const bsl::string &routingKey, rmqt::Mandatory::Value mandatoryFlag, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
rmqt::Result updateTopology (const rmqa::TopologyUpdate &topologyUpdate, const bsls::TimeInterval &timeout=bsls::TimeInterval(0))
 
rmqt::Result waitForConfirms (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 

Detailed Description

Provide a RabbitMQ Producer API for publishing to a specific Exchange.

A RabbitMQ Message Producer API object. A Producer is bound to a specific Exchange. These objects are constructed by rmqa::VHost::createProducer

Constructor & Destructor Documentation

◆ Producer()

BloombergLP::rmqa::Producer::Producer ( bslma::ManagedPtr< rmqp::Producer > &  impl)
explicit

Create an instance of a Producer that will operate through the supplied producer implementation. The Producer object takes ownership of the supplied producer implementation

Member Function Documentation

◆ addTransformer()

void BloombergLP::rmqa::Producer::addTransformer ( const bsl::shared_ptr< rmqp::MessageTransformer > &  transformer)

Registers the tranformation function to be applied to all outgoing messages before being sent to the broker.

Parameters
transformerThe transformation function to be applied to all messages processed by this producer

◆ send() [1/2]

rmqp::Producer::SendStatus BloombergLP::rmqa::Producer::send ( const rmqt::Message message,
const bsl::string &  routingKey,
const rmqp::Producer::ConfirmationCallback confirmCallback,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

Send a message with the given routingKey to the exchange this Producer targets

This call returns immediately when there are fewer unconfirmed messages than the maxOutstandingConfirms limit configured when calling Connection::createProducer

All messages are sent with mandatory = true, immediate = false. Other values can be sent with a different Producer::send call, but these defaults were chosen for safety. Read the warnings carefully.

Parameters
messageThe message to be sent
routingKeyThe routing key (e.g. topic, or queue name) passed to the exchange.
confirmCallbackCalled when the broker explicitly confirms/rejects the message. Messages are automatically retried on reconnection, in which case this method may be called sometime after invoking send.
timeoutHow long to wait for as a relative timeout. If timeout is 0, the method will wait to send message indefinitely
Returns
SENDING When the library accepts this message for sending. Note rmq will resend the message if the connection drops without receiving a confirm
DUPLICATE Returned if a message with the same GUID has already been sent and is awaiting a confirm from the broker. This indicates an issue with the application. When sending duplicate messages a new message should be constructed
TIMEOUT Returned if a message couldn't be enqueued within the timeout time

◆ send() [2/2]

rmqp::Producer::SendStatus BloombergLP::rmqa::Producer::send ( const rmqt::Message message,
const bsl::string &  routingKey,
rmqt::Mandatory::Value  mandatoryFlag,
const rmqp::Producer::ConfirmationCallback confirmCallback,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

Send a message with the given routingKey to the exchange this Producer targets, with the specified mandatory flag. Use the simpler Producer::send() unless you understand & intend to set different values for mandatory.

This call returns immediately when there are fewer unconfirmed messages than the maxOutstandingConfirms limit configured when calling Connection::createProducer

Parameters
messageThe message to be sent
routingKeyThe routing key (e.g. topic, or queue name) passed to the exchange.
mandatorySpecify the mandatory flag: RETURN_UNROUTABLE (Recommended): Any messages not passed to a queue are returned to the sender. confirmCallback will be invoked with a RETURN status. DISCARD_UNROUTABLE (Dangerous): Any messages not passed to a queue are confirmed by the broker. This will cause silent message loss in the event bindings aren't setup as expected.
confirmCallbackCalled when the broker explicitly confirms/rejects the message. Messages are automatically retried on reconnection, in which case this method may be called sometime after invoking send.
timeoutHow long to wait for as a relative timeout. If timeout is 0, the method will wait to send message indefinitely
Returns
SENDING When the library accepts this message for sending. Note rmq will resend the message if the connection drops without receiving a confirm
DUPLICATE Returned if a message with the same GUID has already been sent and is awaiting a confirm from the broker. This indicates an issue with the application. When sending duplicate messages a new message should be constructed
TIMEOUT Returned if a message couldn't be enqueued within the timeout time

◆ updateTopology()

rmqt::Result BloombergLP::rmqa::Producer::updateTopology ( const rmqa::TopologyUpdate topologyUpdate,
const bsls::TimeInterval &  timeout = bsls::TimeInterval(0) 
)

Updates topology and waits for the server to confirm the update status

Parameters
timeoutHow long to wait for. If timeout is 0, the method will indefinitely wait for confirms.
Returns
true if all updates were confirmed by the broker.
false if update failed or waiting timed out

◆ waitForConfirms()

rmqt::Result BloombergLP::rmqa::Producer::waitForConfirms ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())

Wait for all outstanding publisher confirms to arrive.

Parameters
timeoutHow long to wait for. If timeout is 0, the method will indefinitely wait for confirms.
Returns
true if all outstanding confirms have arrived.
false if waiting timed out.

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