RMQ - RabbitMQ C++ Library
Classes | Public Types | Public Member Functions | List of all members
BloombergLP::rmqa::ProducerImpl Class Referenceabstract
Inheritance diagram for BloombergLP::rmqa::ProducerImpl:
Inheritance graph
[legend]
Collaboration diagram for BloombergLP::rmqa::ProducerImpl:
Collaboration graph
[legend]

Classes

class  Factory
 
struct  SharedState
 

Public Types

typedef bsl::unordered_map< bdlb::Guid, rmqp::Producer::ConfirmationCallbackCallbackMap
 
enum  SendStatus {
  SENDING , DUPLICATE , TIMEOUT , INFLIGHT_LIMIT ,
  TRANSFORM_ERROR
}
 Possible results of rmqp::Producer::send.
 
typedef bsl::function< void(const rmqt::Message &, const bsl::string &routingKey, const rmqt::ConfirmResponse &)> ConfirmationCallback
 Invoked on receipt of message confirmation. More...
 

Public Member Functions

 ProducerImpl (uint16_t maxOutstandingConfirms, const bsl::shared_ptr< rmqamqp::SendChannel > &channel, bdlmt::ThreadPool &threadPool, rmqio::EventLoop &eventLoop)
 
void addTransformer (const bsl::shared_ptr< rmqp::MessageTransformer > &transformer) BSLS_KEYWORD_OVERRIDE
 
SendStatus send (const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout) BSLS_KEYWORD_OVERRIDE
 Send a message with the given routingKey to the exchange targeted by the producer. More...
 
SendStatus send (const rmqt::Message &message, const bsl::string &routingKey, rmqt::Mandatory::Value mandatoryFlag, const rmqp::Producer::ConfirmationCallback &confirmCallback, const bsls::TimeInterval &timeout) BSLS_KEYWORD_OVERRIDE
 Send a message with the given routingKey to the exchange targeted by the producer. More...
 
SendStatus trySend (const rmqt::Message &message, const bsl::string &routingKey, const rmqp::Producer::ConfirmationCallback &confirmCallback) BSLS_KEYWORD_OVERRIDE
 Send a message with the given routingKey to the exchange targeted by the producer. More...
 
rmqt::Future updateTopologyAsync (const rmqt::TopologyUpdate &topologyUpdate) BSLS_KEYWORD_OVERRIDE
 Updates topology. More...
 
rmqt::Result waitForConfirms (const bsls::TimeInterval &timeout=bsls::TimeInterval(0)) BSLS_KEYWORD_OVERRIDE
 Wait for all outstanding publisher confirms to arrive. More...
 
virtual void addTransformer (const bsl::shared_ptr< rmqp::MessageTransformer > &transformer)=0
 Adds a transformation function to be run on all messages. More...
 

Member Typedef Documentation

◆ ConfirmationCallback

typedef bsl::function<void(const rmqt::Message&, const bsl::string& routingKey, const rmqt::ConfirmResponse&)> BloombergLP::rmqp::Producer::ConfirmationCallback
inherited

Invoked on receipt of message confirmation.

The user-provided ConfirmationCallback is invoked once RabbitMQ broker provides a guarantee (publisher confirm) that the message is enqueued.

A ConfirmationCallback implementation should perform any commit action, such as confirming to the sender of the message that the action will be completed. For example, an application which consumes from one queue and produces to another should send the acknowledgement to the first queue once the ConfirmationCallback is invoked from the publish.

Member Function Documentation

◆ addTransformer()

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

Adds a transformation function to be run on all messages.

Parameters
transformerThe transformation function

◆ send() [1/2]

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

Send a message with the given routingKey to the exchange targeted by the producer.

The behavior of this method depends on the the number of unconfirmed messages (sent but not yet confirmed by the broker). If this number is smaller than the limit configured when calling rmqa::VHost::createProducer, this method will return immediately. Otherwise it will block until the unconfirmed message count drops below the limit.

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 some time 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 Returned when the library accepts the message for sending. If the connection is lost before receiving the publisher confirm from the broker, the library will retry sending the message.
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. To send the same message multiple times, a new rmqt::Message object must be created every time.
TIMEOUT Returned if a message couldn't be enqueued within the timeout time.

Implements BloombergLP::rmqp::Producer.

Reimplemented in BloombergLP::rmqa::TracingProducerImpl.

◆ send() [2/2]

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

Send a message with the given routingKey to the exchange targeted by the producer.

The behavior of this method depends on the the number of unconfirmed messages (sent but not yet confirmed by the broker). If this number is smaller than the limit configured when calling rmqa::VHost::createProducer, this method will return immediately. Otherwise it will block until the unconfirmed message count drops below the limit.

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 some time 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 Returned when the library accepts the message for sending. If the connection is lost before receiving the publisher confirm from the broker, the library will retry sending the message.
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. To send the same message multiple times, a new rmqt::Message object must be created every time.
TIMEOUT Returned if a message couldn't be enqueued within the timeout time.

Implements BloombergLP::rmqp::Producer.

◆ trySend()

rmqp::Producer::SendStatus BloombergLP::rmqa::ProducerImpl::trySend ( const rmqt::Message message,
const bsl::string &  routingKey,
const rmqp::Producer::ConfirmationCallback confirmCallback 
)
virtual

Send a message with the given routingKey to the exchange targeted by the producer.

The behavior of this method depends on the the number of unconfirmed messages (sent but not yet confirmed by the broker). If this number is smaller than the limit configured when calling rmqa::VHost::createProducer, this method behaves exactly as the method send. Otherwise, unlike send, this method returns immediately with a result indicating that the unconfirmed message limit has been reached.

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 some time after invoking send.
Returns
SENDING Returned when the library accepts the message for sending. If the connection is lost before receiving the publisher confirm from the broker, the library will retry sending the message.
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. To send the same message multiple times, a new rmqt::Message object must be created every time.
INFLIGHT_LIMIT Returned if the unconfirmed message limit has been reached.

Implements BloombergLP::rmqp::Producer.

Reimplemented in BloombergLP::rmqa::TracingProducerImpl.

◆ updateTopologyAsync()

rmqt::Future BloombergLP::rmqa::ProducerImpl::updateTopologyAsync ( const rmqt::TopologyUpdate topologyUpdate)
virtual

Updates topology.

Returns
A Future which, when resolved, will contain the result of the update.

Implements BloombergLP::rmqp::Producer.

◆ waitForConfirms()

rmqt::Result BloombergLP::rmqa::ProducerImpl::waitForConfirms ( const bsls::TimeInterval &  timeout = bsls::TimeInterval(0))
virtual

Wait for all outstanding publisher confirms to arrive.

This method allows

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

Implements BloombergLP::rmqp::Producer.


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