RMQ - RabbitMQ C++ Library
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
BloombergLP::rmqa::TracingMessageGuard Class Reference

Controls acknowledgements passed to broker for consumed messages. More...

#include <rmqa_tracingmessageguard.h>

Inheritance diagram for BloombergLP::rmqa::TracingMessageGuard:
Inheritance graph
[legend]
Collaboration diagram for BloombergLP::rmqa::TracingMessageGuard:
Collaboration graph
[legend]

Classes

class  Factory
 

Public Types

typedef bsl::function< void(const rmqt::ConsumerAck &)> MessageGuardCallback
 

Public Member Functions

rmqp::TransferrableMessageGuard transferOwnership () BSLS_KEYWORD_OVERRIDE
 
 TracingMessageGuard (const rmqt::Message &message, const rmqt::Envelope &envelope, const MessageGuardCallback &ackCallback, rmqp::Consumer *consumer, const bsl::string &queueName, const bsl::shared_ptr< const rmqt::Endpoint > &endpoint, const bsl::shared_ptr< rmqp::ConsumerTracing > &contextFactory)
 
 TracingMessageGuard (const TracingMessageGuard &obj)
 
const rmqt::Messagemessage () const BSLS_KEYWORD_OVERRIDE
 Access the received message. More...
 
const rmqt::Envelopeenvelope () const BSLS_KEYWORD_OVERRIDE
 Access the received message envelope (delivery details) More...
 
void ack () BSLS_KEYWORD_OVERRIDE
 
void nack (bool requeue=true) BSLS_KEYWORD_OVERRIDE
 
virtual rmqp::Consumerconsumer () const BSLS_KEYWORD_OVERRIDE
 Pointer to the Consumer, e.g. to cancel the message flow. More...
 

Protected Types

enum  State { READY , TRANSFERRED , RESOLVED }
 

Protected Member Functions

State state () const
 

Detailed Description

Controls acknowledgements passed to broker for consumed messages.

A TracingMessageGuard is passed to the rmqa::Consumer callback function (defined in rmqp::Consumer) for each message in the event that ConsumerTracing is enabled. The difference being that the ConsumerTracing context is created from the thread that will process the message callback, and the context will be bound to the messageGuard. The object allows acknowledging either positively or negatively, with options to requeue. If a MessageGuard object is allowed to destruct before ack/nack is called a nack with requeue is automatically signaled to the broker.

Member Enumeration Documentation

◆ State

enum BloombergLP::rmqa::MessageGuard::State
protectedinherited

Ready - not resolved yet Invalid - ownership moved Resolved - message (n)acked.

Constructor & Destructor Documentation

◆ TracingMessageGuard() [1/2]

BloombergLP::rmqa::TracingMessageGuard::TracingMessageGuard ( const rmqt::Message message,
const rmqt::Envelope envelope,
const MessageGuardCallback &  ackCallback,
rmqp::Consumer consumer,
const bsl::string &  queueName,
const bsl::shared_ptr< const rmqt::Endpoint > &  endpoint,
const bsl::shared_ptr< rmqp::ConsumerTracing > &  contextFactory 
)

Constructs a new valid guard

Parameters
messageConsumed message
envelopeConsumed delivery metadata
ackCallbackCallback called when resolving message
consumerPointer to the Consumer

◆ TracingMessageGuard() [2/2]

BloombergLP::rmqa::TracingMessageGuard::TracingMessageGuard ( const TracingMessageGuard obj)

During copying obj is invalidated and thereafter cannot be used to (n)ack.

Member Function Documentation

◆ ack()

void BloombergLP::rmqa::MessageGuard::ack ( )
virtualinherited

Acknowledge the received message. Callable only once. Should only be called after the message has been fully processed

A message acknowledgement is fire-and-forget. If the broker does not receive this (e.g. due to connection drop), the message will be redelivered to another consumer.

Implements BloombergLP::rmqp::MessageGuard.

◆ consumer()

rmqp::Consumer * BloombergLP::rmqa::MessageGuard::consumer ( ) const
virtualinherited

Pointer to the Consumer, e.g. to cancel the message flow.

Implements BloombergLP::rmqp::MessageGuard.

◆ envelope()

const rmqt::Envelope & BloombergLP::rmqa::MessageGuard::envelope ( ) const
virtualinherited

Access the received message envelope (delivery details)

Implements BloombergLP::rmqp::MessageGuard.

◆ message()

const rmqt::Message & BloombergLP::rmqa::MessageGuard::message ( ) const
virtualinherited

Access the received message.

Implements BloombergLP::rmqp::MessageGuard.

◆ nack()

void BloombergLP::rmqa::MessageGuard::nack ( bool  requeue = true)
virtualinherited

Negative acknowledge the received message. Callable only once.

Parameters
requeuetrue requeues the message on the broker for redelivery , if false, then the message will be either dead lettered (if a dead letter exchange is specified) or dropped if not.

Implements BloombergLP::rmqp::MessageGuard.

◆ transferOwnership()

rmqp::TransferrableMessageGuard BloombergLP::rmqa::TracingMessageGuard::transferOwnership ( )
virtual

Transfers ownership of the message processing to a MessageGuard that is copyable (shared pointer semantics) RETURN a shared pointer to a valid message guard,

Note
if the MessageGuard has already been resolved or transferred (ack/nack) a warning will be printed

Reimplemented from BloombergLP::rmqa::MessageGuard.


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