libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
BloombergLP::bmqa::AbstractSession Class Reference

A pure protocol for a session.

#include <bmqa_abstractsession.h>

Inheritance diagram for BloombergLP::bmqa::AbstractSession:
BloombergLP::bmqa::MockSession BloombergLP::bmqa::Session

Public Types

typedef bsl::function< void(const bmqa::OpenQueueStatus &result)> OpenQueueCallback
 
typedef bsl::function< void(const bmqa::ConfigureQueueStatus &result)> ConfigureQueueCallback
 
typedef bsl::function< void(const bmqa::CloseQueueStatus &result)> CloseQueueCallback
 

Public Member Functions

virtual ~AbstractSession ()
 Destructor. More...
 
virtual int start (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int startAsync (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual void stop ()
 
virtual void stopAsync ()
 
virtual void finalizeStop ()
 
virtual void loadMessageEventBuilder (MessageEventBuilder *builder)
 
virtual void loadConfirmEventBuilder (ConfirmEventBuilder *builder)
 
virtual void loadMessageProperties (MessageProperties *buffer)
 
virtual int getQueueId (QueueId *queueId, const bmqt::Uri &uri)
 
virtual int getQueueId (QueueId *queueId, const bmqt::CorrelationId &correlationId)
 
virtual int openQueue (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual OpenQueueStatus openQueueSync (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int openQueueAsync (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual void openQueueAsync (bmqa::QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const OpenQueueCallback &callback, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int configureQueue (QueueId *queueId, const bmqt::QueueOptions &options, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual ConfigureQueueStatus configureQueueSync (QueueId *queueId, const bmqt::QueueOptions &options, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int configureQueueAsync (QueueId *queueId, const bmqt::QueueOptions &options, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual void configureQueueAsync (QueueId *queueId, const bmqt::QueueOptions &options, const ConfigureQueueCallback &callback, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int closeQueue (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual CloseQueueStatus closeQueueSync (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int closeQueueAsync (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual void closeQueueAsync (QueueId *queueId, const CloseQueueCallback &callback, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual Event nextEvent (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
virtual int post (const MessageEvent &event)
 
virtual int confirmMessage (const Message &message)
 
virtual int confirmMessage (const MessageConfirmationCookie &cookie)
 
virtual int confirmMessages (ConfirmEventBuilder *builder)
 
virtual int configureMessageDumping (const bslstl::StringRef &command)
 

Member Typedef Documentation

◆ OpenQueueCallback

Invoked as a response to an asynchronous open queue operation, OpenQueueCallback is an alias for a callback function object (functor) that takes as an argument the specified result, providing the result and context of the requested operation.

◆ ConfigureQueueCallback

Invoked as a response to an asynchronous configure queue operation, ConfigureQueueCallback is an alias for a callback function object (functor) that takes as an argument the specified result, providing the result and context of the requested operation.

◆ CloseQueueCallback

Invoked as a response to an asynchronous close queue operation, CloseQueueCallback is an alias for a callback function object (functor) that takes as an argument the specified result, providing the result and context of the requested operation.

Constructor & Destructor Documentation

◆ ~AbstractSession()

virtual BloombergLP::bmqa::AbstractSession::~AbstractSession ( )
virtual

Member Function Documentation

◆ start()

virtual int BloombergLP::bmqa::AbstractSession::start ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())
virtual

Session management

Connect to the BlazingMQ broker and start the message processing for this Session. This method blocks until either the Session is connected to the broker, fails to connect, or the operation times out. If the optionally specified timeout is not populated, use the one defined in the session options. Return 0 on success, or a non-zero value corresponding to the bmqt::GenericResult::Enum enum values otherwise. The behavior is undefined if this method is called on an already started Session.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ startAsync()

virtual int BloombergLP::bmqa::AbstractSession::startAsync ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())
virtual

Connect to the BlazingMQ broker and start the message processing for this Session. This method returns without blocking. The result of the operation is communicated with a session event. If the optionally specified timeout is not populated, use the one defined in the session options. Return 0 on success (this doesn't imply the session is connected !), or a non-zero value corresponding to the bmqt::GenericResult::Enum enum values otherwise. The behavior is undefined if this method is called on an already started Session.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ stop()

virtual void BloombergLP::bmqa::AbstractSession::stop ( )
virtual

Gracefully disconnect from the BlazingMQ broker and stop the operation of this Session. This method blocks waiting for all already invoked event handlers to exit and all session-related operations to be finished. No other method but start() may be used after this method returns. This method must NOT be called if the session is in synchronous mode (i.e., not using the EventHandler), stopAsync() should be called in this case.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ stopAsync()

virtual void BloombergLP::bmqa::AbstractSession::stopAsync ( )
virtual

Disconnect from the BlazingMQ broker and stop the operation of this Session. This method returns without blocking and neither enforce nor waits for any already started session-related operation to be finished. No method may be used after this method returns.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ finalizeStop()

virtual void BloombergLP::bmqa::AbstractSession::finalizeStop ( )
virtual

DEPRECATED

This method is only to be used if the session is in synchronous mode (i.e., not using the EventHandler): it must be called once all threads getting events with nextEvent() have been joined.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ loadMessageEventBuilder()

virtual void BloombergLP::bmqa::AbstractSession::loadMessageEventBuilder ( MessageEventBuilder builder)
virtual

Load into the specified builder an instance of bmqa::MessageEventBuilder that can be used to build message event for posting on this session. The behavior is undefined unless the session has been successfully started and builder is non-null. Note that lifetime of the loaded object is bound by the lifetime of this session instance (i.e., loaded instance cannot outlive this session instance). Also note that the MessageEventBuilder objects are pooled, so this operation is cheap, and MessageEventBuilder can be obtained on demand and kept on the stack.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ loadConfirmEventBuilder()

virtual void BloombergLP::bmqa::AbstractSession::loadConfirmEventBuilder ( ConfirmEventBuilder builder)
virtual

Load into the specified builder an instance of bmqa::ConfirmEventBuilder that can be used to build a batch of CONFIRM messages for sending to the broker. The behavior is undefined unless the session has been successfully started and builder is non-null. Note that the lifetime of the loaded object is bound by the lifetime of this session instance (i.e., loaded instance cannot outlive this session instance).

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ loadMessageProperties()

virtual void BloombergLP::bmqa::AbstractSession::loadMessageProperties ( MessageProperties buffer)
virtual

Load into the specified buffer an instance of MessageProperties that can be used to specify and associate properties while building a bmqa::Message. The behavior is undefined unless the session has been successfully started and buffer is non-null. Note that lifetime of the loaded object is bound by the lifetime of this session instance (i.e., loaded instance cannot outlive this session instance).

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ getQueueId() [1/2]

virtual int BloombergLP::bmqa::AbstractSession::getQueueId ( QueueId queueId,
const bmqt::Uri uri 
)
virtual

Queue management

Load in the specified queueId the queue corresponding to the specified uri and return 0 if such a queue was found, or leave queueId untouched and return a non-zero value if no queue corresponding to uri is currently open.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ getQueueId() [2/2]

virtual int BloombergLP::bmqa::AbstractSession::getQueueId ( QueueId queueId,
const bmqt::CorrelationId correlationId 
)
virtual

Load in the specified queueId the queue corresponding to the specified correlationId and return 0 if such a queue was found, or leave queueId untouched and return a non-zero value if no queue corresponding to correlationId is currently open.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ openQueue()

virtual int BloombergLP::bmqa::AbstractSession::openQueue ( QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

DEPRECATED: Use the openQueueSync(QueueId *queueId...) instead. This method will be marked as BSLS_ANNOTATION_DEPRECATED in future release of libbmq.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ openQueueSync()

virtual OpenQueueStatus BloombergLP::bmqa::AbstractSession::openQueueSync ( QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

Open the queue having the specified uri with the specified flags (a combination of the values defined in bmqt::QueueFlags::Enum), using the specified queueId to correlate events related to that queue. The object queueId referring to is modified, so the queueId represents the actual queue uri, flags and options. Return a result providing the status and context of the operation. Use the optionally specified options to configure some advanced settings. Note that this operation fails if queueId is non-unique. If the optionally specified timeout is not populated, use the one defined in the session options. This operation will block until either success, failure, or timing out happens.

THREAD: Note that calling this method from the event processing thread(s) (i.e., from the EventHandler callback, if provided) WILL lead to a DEADLOCK.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ openQueueAsync() [1/2]

virtual int BloombergLP::bmqa::AbstractSession::openQueueAsync ( QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

DEPRECATED: Use the openQueueAsync(...) with callback flavor instead. This method will be marked as BSLS_ANNOTATION_DEPRECATED in future release of libbmq.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ openQueueAsync() [2/2]

virtual void BloombergLP::bmqa::AbstractSession::openQueueAsync ( bmqa::QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const OpenQueueCallback callback,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

Asynchronously open the queue having the specified uri with the specified flags (a combination of the values defined in bmqt::QueueFlags::Enum), using the specified queueId to correlate events related to that queue and the optionally specified options to configure some advanced settings. The object queueId referring to is modified, so the queueId represents the actual queue uri, flags and options. The result of the operation is communicated to the specified callback via a bmqa::OpenQueueStatus, providing the status and context of the requested operation. Note that this operation fails if queueId is non-unique. If the optionally specified timeout is not populated, use the one defined in the session options.

THREAD: The callback will ALWAYS be invoked from the EventHandler thread(s) (or if a SessionEventHandler was not specified, from the thread invoking nextEvent).

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ configureQueue()

virtual int BloombergLP::bmqa::AbstractSession::configureQueue ( QueueId queueId,
const bmqt::QueueOptions options,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

DEPRECATED: Use the 'configureQueueSync(QueueId *queueId...) instead. This method will be marked as BSLS_ANNOTATION_DEPRECATED in future release of libbmq.

Reimplemented in BloombergLP::bmqa::MockSession, and BloombergLP::bmqa::Session.

◆ configureQueueSync()

virtual ConfigureQueueStatus BloombergLP::bmqa::AbstractSession::configureQueueSync ( QueueId queueId,
const bmqt::QueueOptions options,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

Configure the queue identified by the specified queueId using the specified options and return a result providing the status and context of the operation. Fields from options that have not been explicitly set will not be modified. If the optionally specified timeout is not populated, use the one defined in the session options. This operation returns error if there is a pending configure for the same queue. This operation will block until either success, failure, or timing out happens.

THREAD: Note that calling this method from the event processing thread(s) (i.e., from the EventHandler callback, if provided) WILL lead to a DEADLOCK.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ configureQueueAsync() [1/2]

virtual int BloombergLP::bmqa::AbstractSession::configureQueueAsync ( QueueId queueId,
const bmqt::QueueOptions options,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

DEPRECATED: Use the configureQueueAsync(...) with callback flavor instead. This method will be marked as BSLS_ANNOTATION_DEPRECATED in future release of libbmq.

Reimplemented in BloombergLP::bmqa::MockSession, and BloombergLP::bmqa::Session.

◆ configureQueueAsync() [2/2]

virtual void BloombergLP::bmqa::AbstractSession::configureQueueAsync ( QueueId queueId,
const bmqt::QueueOptions options,
const ConfigureQueueCallback callback,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

◆ closeQueue()

virtual int BloombergLP::bmqa::AbstractSession::closeQueue ( QueueId queueId,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

DEPRECATED: Use the 'closeQueueSync(QueueId *queueId...) instead. This method will be marked as BSLS_ANNOTATION_DEPRECATED in future release of libbmq.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ closeQueueSync()

virtual CloseQueueStatus BloombergLP::bmqa::AbstractSession::closeQueueSync ( QueueId queueId,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

Close the queue identified by the specified queueId and return a result providing the status and context of the operation. If the optionally specified timeout is not populated, use the one defined in the session options. Any outstanding configureQueue request for this queueId will be canceled. This operation will block until either success, failure, or timing out happens. Once this method returns, there is guarantee that no more messages and events for this queueId will be received. Note that successful processing of this request in the broker closes this session's view of the queue; the underlying queue may not be deleted in the broker. When this method returns, the correlationId associated to the queue is cleared.

THREAD: Note that calling this method from the event processing thread(s) (i.e., from the EventHandler callback, if provided) WILL lead to a DEADLOCK.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ closeQueueAsync() [1/2]

virtual int BloombergLP::bmqa::AbstractSession::closeQueueAsync ( QueueId queueId,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

DEPRECATED: Use the closeQueueAsync(...) with callback flavor instead. This method will be marked as BSLS_ANNOTATION_DEPRECATED in future release of libbmq.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ closeQueueAsync() [2/2]

virtual void BloombergLP::bmqa::AbstractSession::closeQueueAsync ( QueueId queueId,
const CloseQueueCallback callback,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)
virtual

Asynchronously close the queue identified by the specified queueId. Any outstanding configureQueue requests will be canceled. The result of the operation is communicated to the specified callback via a bmqa::CloseQueueStatus, providing the status and context of the operation. If the optionally specified timeout is not populated, use the one defined in the session options. Note that successful processing of this request in the broker closes this session's view of the queue; the underlying queue may not be deleted in the broker. The correlationId associated to the queue remains valid until the bmqa::CloseQueueStatus result has been received and processed by the callback, after which it will be cleared and no more messages and events for this queueId will be received.

THREAD: The callback will ALWAYS be invoked from the EventHandler thread(s) (or if a SessionEventHandler was not specified, from the thread invoking nextEvent).

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ nextEvent()

virtual Event BloombergLP::bmqa::AbstractSession::nextEvent ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())
virtual

Queue manipulation

Return the next available event received for this session. If there is no event available, this method blocks for up to the optionally specified timeout time interval for an event to arrive. An empty time interval for timeout (the default) indicates that the method should not timeout (the method will not return until the next event is available). Return a bmqa::SessionEvent of type bmqt::SessionEventType::e_TIMEOUT if a timeout was specified and that timeout expired before any event was received. Note that this method can only be used if the session is in synchronous mode (ie not using the EventHandler). The behavior is undefined unless the session was started.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ post()

virtual int BloombergLP::bmqa::AbstractSession::post ( const MessageEvent event)
virtual

Asynchronously post the specified event that must contain one or more Messages. The return value is one of the values defined in the bmqt::PostResult::Enum enum. Return zero on success and a non-zero value otherwise. Note that success implies that SDK has accepted the event and will eventually deliver it to the broker. The behavior is undefined unless the session was started.

Reimplemented in BloombergLP::bmqa::MockSession, and BloombergLP::bmqa::Session.

◆ confirmMessage() [1/2]

virtual int BloombergLP::bmqa::AbstractSession::confirmMessage ( const Message message)
virtual

Asynchronously confirm the receipt of the specified message. This indicates that the application is done processing the message and that the broker can safely discard it from the queue according to the retention policy set up for that queue. Return 0 on success, and a non-zero value otherwise. Note that success implies that SDK has accepted the message and will eventually send confirmation notification to the broker.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ confirmMessage() [2/2]

virtual int BloombergLP::bmqa::AbstractSession::confirmMessage ( const MessageConfirmationCookie cookie)
virtual

Asynchronously confirm the receipt of the message with which the specified cookie is associated. This indicates that the application is done processing the message and that the broker can safely discard it from the queue according to the retention policy set up for that queue. Return 0 on success, and a non-zero value otherwise. Note that success implies that SDK has accepted the message and will eventually send confirmation notification to the broker.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ confirmMessages()

virtual int BloombergLP::bmqa::AbstractSession::confirmMessages ( ConfirmEventBuilder builder)
virtual

Asynchronously confirm the receipt of the batch of CONFIRM messages contained in the specified builder. This indicates that the application is done processing all of the messages and that the broker can safely discard them from the queue according to the retention policy set up for that queue. Return 0 on success, and a non-zero value otherwise. Note that in case of success, the instance pointed by the builder will be reset. Also note that success implies that SDK has accepted all of the messages in builder and will eventually send confirmation notification to the broker. Behavior is undefined unless builder is non-null.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.

◆ configureMessageDumping()

virtual int BloombergLP::bmqa::AbstractSession::configureMessageDumping ( const bslstl::StringRef &  command)
virtual

Debugging related

Configure this session instance to dump messages to the installed logger at ball::Severity::INFO level according to the specified command that should adhere to the following pattern:

IN|OUT ON|OFF|100|10s

where each token has a specific meaning:

  • IN : incoming (PUSH and ACK) events
  • OUT : outgoing (PUT and CONFIRM) events
  • ON : turn on message dumping until explicitly turned off
  • OFF : turn off message dumping
  • 100 : turn on message dumping for the next 100 messages
  • 10s : turn on message dumping for the next 10 seconds Note that above, 100 and 10 numerical values are for just for illustration purposes, and application can choose an appropriate value for them. Also note that pattern is case-insensitive. Return zero if command is valid and message dumping has been configured, non-zero value otherwise. The behavior is undefined unless the session has been started.

Reimplemented in BloombergLP::bmqa::Session, and BloombergLP::bmqa::MockSession.


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