libbmq  a5f8a06ba1d16cb5a65643e1fa7f1a1d6aadef40
BloombergLP::bmqa::MockSession Class Reference

Mechanism to mock a bmqa::Session

#include <bmqa_mocksession.h>

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

Public Types

typedef bsl::function< void(const char *description, const char *file, int line)> FailureCb
 
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

 MockSession (const bmqt::SessionOptions &options=bmqt::SessionOptions(), bslma::Allocator *allocator=0)
 
 MockSession (bslma::ManagedPtr< SessionEventHandler > eventHandler, const bmqt::SessionOptions &options=bmqt::SessionOptions(), bslma::Allocator *allocator=0)
 
 ~MockSession () BSLS_KEYWORD_OVERRIDE
 Stop the MockSession and destroy this object. More...
 
void enqueueEvent (const bmqa::Event &event)
 
bool emitEvent (int numEvents=1)
 
Call & expect_start (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_startAsync (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_stop ()
 
Call & expect_stopAsync ()
 
Call & expect_finalizeStop ()
 
Call & expect_openQueue (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_openQueueSync (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_openQueueAsync (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_openQueueAsync (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())
 
Call & expect_closeQueue (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_closeQueueSync (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_closeQueueAsync (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_closeQueueAsync (QueueId *queueId, const CloseQueueCallback &callback, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_configureQueue (QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_configureQueueSync (QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_configureQueueAsync (QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_configureQueueAsync (QueueId *queueId, const bmqt::QueueOptions &options, const ConfigureQueueCallback &callback, const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_nextEvent (const bsls::TimeInterval &timeout=bsls::TimeInterval())
 
Call & expect_post (const MessageEvent &messageEvent)
 
Call & expect_confirmMessage (const Message &message)
 
Call & expect_confirmMessage (const MessageConfirmationCookie &cookie)
 
Call & expect_confirmMessages (ConfirmEventBuilder *builder)
 
int start (const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
int startAsync (const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
void stop () BSLS_KEYWORD_OVERRIDE
 
void stopAsync () BSLS_KEYWORD_OVERRIDE
 
void finalizeStop () BSLS_KEYWORD_OVERRIDE
 
void loadMessageEventBuilder (MessageEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
 
void loadConfirmEventBuilder (ConfirmEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
 
void loadMessageProperties (MessageProperties *buffer) BSLS_KEYWORD_OVERRIDE
 
int getQueueId (QueueId *queueId, const bmqt::Uri &uri) BSLS_KEYWORD_OVERRIDE
 
int getQueueId (QueueId *queueId, const bmqt::CorrelationId &correlationId) BSLS_KEYWORD_OVERRIDE
 
int openQueue (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
OpenQueueStatus openQueueSync (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
int openQueueAsync (QueueId *queueId, const bmqt::Uri &uri, bsls::Types::Uint64 flags, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
void openQueueAsync (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()) BSLS_KEYWORD_OVERRIDE
 
int configureQueue (QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
ConfigureQueueStatus configureQueueSync (QueueId *queueId, const bmqt::QueueOptions &options, const bsls::TimeInterval &timeout) BSLS_KEYWORD_OVERRIDE
 
int configureQueueAsync (QueueId *queueId, const bmqt::QueueOptions &options=bmqt::QueueOptions(), const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
void configureQueueAsync (QueueId *queueId, const bmqt::QueueOptions &options, const ConfigureQueueCallback &callback, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
int closeQueue (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
CloseQueueStatus closeQueueSync (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
int closeQueueAsync (QueueId *queueId, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
void closeQueueAsync (QueueId *queueId, const CloseQueueCallback &callback, const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
Event nextEvent (const bsls::TimeInterval &timeout=bsls::TimeInterval()) BSLS_KEYWORD_OVERRIDE
 
int post (const MessageEvent &messageEvent) BSLS_KEYWORD_OVERRIDE
 
int confirmMessage (const Message &message) BSLS_KEYWORD_OVERRIDE
 
int confirmMessage (const MessageConfirmationCookie &cookie) BSLS_KEYWORD_OVERRIDE
 
int confirmMessages (ConfirmEventBuilder *builder) BSLS_KEYWORD_OVERRIDE
 
int configureMessageDumping (const bslstl::StringRef &command) BSLS_KEYWORD_OVERRIDE
 
void setFailureCallback (const FailureCb &failureCb)
 
bool popPostedEvent (bmqa::MessageEvent *event)
 
size_t unconfirmedMessages () const
 

Static Public Member Functions

static void initialize (bslma::Allocator *allocator=0)
 
static void shutdown ()
 

Member Typedef Documentation

◆ FailureCb

typedef bsl::function< void(const char* description, const char* file, int line)> BloombergLP::bmqa::MockSession::FailureCb

Callback used to inform the test driver of an assertion failure. The application test driver using the MockSession may provide an implementation that makes the test driver fail (for instance, calling BDE's test driver ASSERT macro).

◆ OpenQueueCallback

typedef bsl::function<void(const bmqa::OpenQueueStatus& result)> BloombergLP::bmqa::AbstractSession::OpenQueueCallback
inherited

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

typedef bsl::function<void(const bmqa::ConfigureQueueStatus& result)> BloombergLP::bmqa::AbstractSession::ConfigureQueueCallback
inherited

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

typedef bsl::function<void(const bmqa::CloseQueueStatus& result)> BloombergLP::bmqa::AbstractSession::CloseQueueCallback
inherited

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

◆ MockSession() [1/2]

BloombergLP::bmqa::MockSession::MockSession ( const bmqt::SessionOptions options = bmqt::SessionOptions(),
bslma::Allocator *  allocator = 0 
)
explicit

Create a new MockSession in synchronous mode using the optionally specified options. In such mode, events have to be fetched by the application using the nextEvent() method. Optionally specify an allocator used to supply memory. If allocator is 0, the currently installed default allocator is used.

◆ MockSession() [2/2]

BloombergLP::bmqa::MockSession::MockSession ( bslma::ManagedPtr< SessionEventHandler eventHandler,
const bmqt::SessionOptions options = bmqt::SessionOptions(),
bslma::Allocator *  allocator = 0 
)
explicit

Create a MockSession in asynchronous mode using the specified eventHandler as callback for event processing and the optionally specified options. Optionally specify an allocator used to supply memory. If the optionally specified allocator is 0, the currently installed default allocator is used.

◆ ~MockSession()

BloombergLP::bmqa::MockSession::~MockSession ( )

Member Function Documentation

◆ initialize()

static void BloombergLP::bmqa::MockSession::initialize ( bslma::Allocator *  allocator = 0)
static

Perform a one time initialization needed by components used in MockSession and MockSessionUtil. This method only needs to be called once before any other method, but can be called multiple times provided that for each call to initialize there is a corresponding call to shutdown. Use the optionally specified allocator for any memory allocation, or the global allocator if none is provided. Note that specifying the allocator is provided for test drivers only, and therefore users should let it default to the global allocator. NOTE: This method will need to be invoked only if the application needs to use MockSessionUtil outside the scope of MockSession.

◆ shutdown()

static void BloombergLP::bmqa::MockSession::shutdown ( )
static

Pendant operation of the initialize one. The number of calls to shutdown must equal the number of calls to initialize, without corresponding shutdown calls, to fully destroy the objects. It is safe to call initialize after calling shutdown. The behaviour is undefined if shutdown is called without initialize first being called.

◆ enqueueEvent()

void BloombergLP::bmqa::MockSession::enqueueEvent ( const bmqa::Event event)

Enqueue the specified event in the queue of events to be emitted. NOTE: This method is unique to MockSession and is valid only in unit tests.

◆ emitEvent()

bool BloombergLP::bmqa::MockSession::emitEvent ( int  numEvents = 1)

Emit the specified number of numEvents from the queue of events to be emitted. Return true if at least one event was emitted, and false otherwise. NOTE: This method is unique to MockSession and is valid only in unit tests.

◆ expect_start()

Call& BloombergLP::bmqa::MockSession::expect_start ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())

◆ expect_startAsync()

Call& BloombergLP::bmqa::MockSession::expect_startAsync ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())

◆ expect_stop()

Call& BloombergLP::bmqa::MockSession::expect_stop ( )

◆ expect_stopAsync()

Call& BloombergLP::bmqa::MockSession::expect_stopAsync ( )

◆ expect_finalizeStop()

Call& BloombergLP::bmqa::MockSession::expect_finalizeStop ( )

◆ expect_openQueue()

Call& BloombergLP::bmqa::MockSession::expect_openQueue ( QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_openQueueSync()

Call& BloombergLP::bmqa::MockSession::expect_openQueueSync ( QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_openQueueAsync() [1/2]

Call& BloombergLP::bmqa::MockSession::expect_openQueueAsync ( QueueId queueId,
const bmqt::Uri uri,
bsls::Types::Uint64  flags,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_openQueueAsync() [2/2]

Call& BloombergLP::bmqa::MockSession::expect_openQueueAsync ( 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() 
)

◆ expect_closeQueue()

Call& BloombergLP::bmqa::MockSession::expect_closeQueue ( QueueId queueId,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_closeQueueSync()

Call& BloombergLP::bmqa::MockSession::expect_closeQueueSync ( QueueId queueId,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_closeQueueAsync() [1/2]

Call& BloombergLP::bmqa::MockSession::expect_closeQueueAsync ( QueueId queueId,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_closeQueueAsync() [2/2]

Call& BloombergLP::bmqa::MockSession::expect_closeQueueAsync ( QueueId queueId,
const CloseQueueCallback callback,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_configureQueue()

Call& BloombergLP::bmqa::MockSession::expect_configureQueue ( QueueId queueId,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_configureQueueSync()

Call& BloombergLP::bmqa::MockSession::expect_configureQueueSync ( QueueId queueId,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_configureQueueAsync() [1/2]

Call& BloombergLP::bmqa::MockSession::expect_configureQueueAsync ( QueueId queueId,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_configureQueueAsync() [2/2]

Call& BloombergLP::bmqa::MockSession::expect_configureQueueAsync ( QueueId queueId,
const bmqt::QueueOptions options,
const ConfigureQueueCallback callback,
const bsls::TimeInterval &  timeout = bsls::TimeInterval() 
)

◆ expect_nextEvent()

Call& BloombergLP::bmqa::MockSession::expect_nextEvent ( const bsls::TimeInterval &  timeout = bsls::TimeInterval())

◆ expect_post()

Call& BloombergLP::bmqa::MockSession::expect_post ( const MessageEvent messageEvent)

◆ expect_confirmMessage() [1/2]

Call& BloombergLP::bmqa::MockSession::expect_confirmMessage ( const Message message)

◆ expect_confirmMessage() [2/2]

Call& BloombergLP::bmqa::MockSession::expect_confirmMessage ( const MessageConfirmationCookie cookie)

◆ expect_confirmMessages()

Call& BloombergLP::bmqa::MockSession::expect_confirmMessages ( ConfirmEventBuilder builder)

Expect a call to the function and return a reference offering modifiable access to the corresponding Call object.

NOTE: Do not use these method directly, use the macro BMQA_EXPECT_CALL instead.

◆ start()

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ startAsync()

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

Start the MockSession with an optionally specified timeout. The return values are elucidated in bmqt::GenericResult. In general a call to start or startAsync emits a SessionEvent of type e_CONNECTED or e_CONNECTION_TIMEOUT.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ stop()

void BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ stopAsync()

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

Stop the MockSession. In general a call to start or startAsync emits a SessionEvent of type e_DISCONNECTED or e_CONNECTION_TIMEOUT.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ finalizeStop()

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

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 from BloombergLP::bmqa::AbstractSession.

◆ loadMessageEventBuilder()

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

Load the MessageEventBuilder into the specified builder output parameter.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ loadConfirmEventBuilder()

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

Load the ConfirmEventBuilder into the specified builder output parameter.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ loadMessageProperties()

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

Load the MessageProperties into the specified buffer output parameter.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ getQueueId() [1/2]

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

Queue management

Load QueueId object associated with the specified uri into the specified queueId output parameter.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ getQueueId() [2/2]

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

Load QueueId object associated with the specified correlationId into the specified queueId output parameter.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ openQueue()

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ openQueueSync()

OpenQueueStatus BloombergLP::bmqa::MockSession::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. In general, a call to openQueueSync emits nothing.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ openQueueAsync() [1/2]

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ openQueueAsync() [2/2]

void BloombergLP::bmqa::MockSession::openQueueAsync ( 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). 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 an automatically generated correlation queueId and the status and context of the requested operation. Use the optionally specified options to configure some advanced settings. In general, a call to openQueueAsync does not emit a SessionEvent, but rather invokes the callback (if provided) instead when the corresponding emitEvent is called.

NOTE: openQueueAsync updates the queue state to e_OPENING which is further updated upon invocation of the callback (if provided) with a successful bmqa::OpenQueueStatus.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ configureQueue()

int BloombergLP::bmqa::MockSession::configureQueue ( QueueId queueId,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
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 from BloombergLP::bmqa::AbstractSession.

◆ configureQueueSync()

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

Configure the queue identified by the specified queueId using the specified options to configure some advanced settings and return a result providing the status and context of the operation. In general, a call to configureQueueSync emits nothing.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ configureQueueAsync() [1/2]

int BloombergLP::bmqa::MockSession::configureQueueAsync ( QueueId queueId,
const bmqt::QueueOptions options = bmqt::QueueOptions(),
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 from BloombergLP::bmqa::AbstractSession.

◆ configureQueueAsync() [2/2]

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

Asynchronously configure the queue identified by the specified queueId using the specified options to configure some advanced settings. The result of the operation is communicated to the specified callback via a bmqa::ConfigureQueueStatus, providing the status and context of the requested operation. In general, a call to configureQueueAsync does not emit a SessionEvent, but rather invokes the callback (if provided) instead when the corresponding emitEvent is called.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ closeQueue()

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ closeQueueSync()

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

Close the queue identified by the specified queueId using the specified timeout. Populate the optionally specified result with the status and context of the operation and return a value providing the status of the operation. In general, a call to closeQueueSync emits nothing.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ closeQueueAsync() [1/2]

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ closeQueueAsync() [2/2]

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

Asynchronously close the queue identified by the specified queueId using the specified timeout. The result of the operation is communicated to the specified callback via a bmqa::CloseQueueStatus, providing the status and context of the requested operation. In general, a call to closeQueueAsync does not emit a SessionEvent, but rather invokes the callback (if provided) instead when the corresponding emitEvent is called.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ nextEvent()

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

Returns the nextEvent emitted.

NOTE: This method should only be used when the MockSession has been created in synchronous mode. It is invalid if used in asynchronous mode and your test case is likely to be faulty if used with such a set up.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ post()

int BloombergLP::bmqa::MockSession::post ( const MessageEvent messageEvent)
virtual

Post the specified messageEvent. Return values are defined as per bmqt::PostResult. In general a call to post emits a MessageEvent of type e_ACK or no response if acks are not requested.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ confirmMessage() [1/2]

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ confirmMessage() [2/2]

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ confirmMessages()

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

Confirm messages specified by the message, cookie or builder. Return values are defined as per bmqt::GenericResult. No event is emitted for calls to confirmMessage.

Reimplemented from BloombergLP::bmqa::AbstractSession.

◆ configureMessageDumping()

int BloombergLP::bmqa::MockSession::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 from BloombergLP::bmqa::AbstractSession.

◆ setFailureCallback()

void BloombergLP::bmqa::MockSession::setFailureCallback ( const FailureCb failureCb)
inline

Set the failure callback of to be the specified failureCb. This callback is invoked whenever an expectation set by the test driver is not met.

◆ popPostedEvent()

bool BloombergLP::bmqa::MockSession::popPostedEvent ( bmqa::MessageEvent event)
inline

Load into the specified event the next posted event on this session, if any, and return true; leave event unchanged and return false otherwise.

◆ unconfirmedMessages()

size_t BloombergLP::bmqa::MockSession::unconfirmedMessages ( ) const
inline

Get the number of unconfirmed messages. This corresponds to the number of push messages enqueued to the session object but not yet confirmed by the application.


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