Provide a RabbitMQ Producer API for publishing to a specific Exchange.
More...
#include <rmqa_producer.h>
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
◆ 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
◆ addTransformer()
Registers the tranformation function to be applied to all outgoing messages before being sent to the broker.
- Parameters
-
| transformer | The transformation function to be applied to all messages processed by this producer |
◆ send() [1/2]
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
-
| message | The message to be sent |
| routingKey | The routing key (e.g. topic, or queue name) passed to the exchange. |
| confirmCallback | Called 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. |
| timeout | How 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]
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
-
| message | The message to be sent |
| routingKey | The routing key (e.g. topic, or queue name) passed to the exchange. |
| mandatory | Specify 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. |
| confirmCallback | Called 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. |
| timeout | How 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
-
| timeout | How 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
-
| timeout | How 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: