com::pcbsys::nirvana::client::nQueue Class Reference

This class provides a Queue mechanism. More...

#include <nQueue.h>

Inheritance diagram for com::pcbsys::nirvana::client::nQueue:
com::pcbsys::nirvana::client::nAbstractChannel

Public Member Functions

void addConnectionListener (nChannelConnectionListener *pListener)
 Adds a nChannelConnectionListener to this queue so that when new connections are made to this queue the listener is notified.
 
nQueueAsyncReadercreateAsyncReader (nQueueReaderContext *pContext)
 Creates an Asynchronous queue reader.
 
nQueueAsyncTransactionReadercreateAsyncTransactionalReader (nQueueReaderContext *pContext)
 Creates an Asynchronous Transactional queue reader.
 
nQueueSyncReadercreateReader (nQueueReaderContext *pContext)
 Creates a Synchronous queue reader.
 
nQueueSyncTransactionReadercreateTransactionalReader (nQueueReaderContext *pContext)
 Creates a Synchronous Transaction queue reader.
 
nQueueDetailsgetDetails ()
 This method returns the current queue details.
 
std::string getName ()
 Gets the name of this queue.
 
nChannelAttributesgetQueueAttributes ()
 This method will return the nChannelAttributes associated with the nQueue object.
 
void purge ()
 Deletes all undelivered events from the queue.
 
void purge (std::string &selector)
 Deletes all undelivered events from the queue.
 
long push (nConsumeEvent *pEvent)
 Pushes an event on to the queue.
 
void removeConnectionListener (nChannelConnectionListener *pListener)
 Removes the connection listener to this queue.
 
int size ()
 Returns the number of events waiting in the queue.
 
- Public Member Functions inherited from com::pcbsys::nirvana::client::nAbstractChannel
int getQueueSize ()
 Returns the size of the underlying event queue waiting for delivery via the go method.
 
nSessiongetSession ()
 Returns the nSession used to create/find this channel.
 
void updateProtobufDefinitions (const std::vector< ProtobufDescriptor * > &descriptors)
 Update the Protocol Buffer definition for the store.
 

Detailed Description

This class provides a Queue mechanism.

It allows for multiple users to pop events from the queue and multiple users to push events on to the queue.

However, a queue differs from a channel in that an event can only be popped by one user. This means that an event is only delivered to one client. While a channel it is delivered to all users who are subscribed.

The queue also offers a peek method. This method uses a window over the queue so that the entire queue does not need to be sent in one hit.

Four different Queue reading models are supported, these are

Synchronous Here the client will call pop() whenever the client wants to retrieve an event from the server. The server will automatically acknowledge that the client has received this event.
Synchronous Transactional This is similar in operation to the Synchronous model, except the server does not auto acknowledge the events, this enables the client to perform commit() or rollback() operations.
Asynchronous In this model the server will record that the client is interested in events from this queue and will maintain an outstanding pop() and as events are received on the queue they are automatically delivered to the client via a callback. The events are auto acknowledged on the server once they have been delivered to the client.
Asynchronous Transactional

This is similar in operation to the Asynchronous model, except the server does not auto acknowledge the events, this enables the client to perform commit() or rollback() operations. The server will stop delivering events to this client once the WindowSize has been reached, the client will need to call either commit() or rollback() before events are delivered again.

In both transactional models, when a rollback() is called any events sent since the last commit() or rollback() will be redelivered to all registered clients. This means the client may not receive these events again, but rather, they are redistributed amongst the current clients.

Member Function Documentation

◆ addConnectionListener()

void com::pcbsys::nirvana::client::nQueue::addConnectionListener ( nChannelConnectionListener pListener)

Adds a nChannelConnectionListener to this queue so that when new connections are made to this queue the listener is notified.

Parameters
*pListenerto add
Exceptions
nRequestTimedOutExceptionif the request exceeded the timeout value
nSessionNotConnectedExceptionThe session is not currently connected to the server
nUnexpectedResponseExceptionReceived a response from the server for which we can not deal with, see the message for further information
nIllegalArgumentExceptionPassed am illegal argument. This means the value passed is outside expected limits, or has already been set.
nSessionPausedExceptionThe session is currently paused, please resume

◆ createAsyncReader()

nQueueAsyncReader * com::pcbsys::nirvana::client::nQueue::createAsyncReader ( nQueueReaderContext pContext)

Creates an Asynchronous queue reader.

In this model the server will record that the client is interested in events from this queue and will maintain an outstanding pop() and as events are received on the queue they are automatically delivered to the client via a callback. The events are auto acknowledged on the server once they have been delivered to the client.

Parameters
*pContextcontains the readers context to be used during construction of the reader
Returns
nQueueAsyncReader
Exceptions
nIllegalArgumentExceptionif the context is null or some non specified error is found
nSecurityExceptionif the subject does not have the correct permissions

◆ createAsyncTransactionalReader()

nQueueAsyncTransactionReader * com::pcbsys::nirvana::client::nQueue::createAsyncTransactionalReader ( nQueueReaderContext pContext)

Creates an Asynchronous Transactional queue reader.

This is similar in operation to the Asynchronous model, except the server does not auto acknowledge the events, this enables the client to perform commit() or rollback() operations. The server will stop delivering events to this client once the WindowSize has been reached, the client will need to call either commit() or rollback() before events are delivered again.

Parameters
*pContextcontains the readers context to be used during construction of the reader
Returns
nQueueAsyncTransactionReader
Exceptions
nIllegalArgumentExceptionif the context is null or some non specified error is found
nSecurityExceptionif the subject does not have the correct permissions

◆ createReader()

nQueueSyncReader * com::pcbsys::nirvana::client::nQueue::createReader ( nQueueReaderContext pContext)

Creates a Synchronous queue reader.

Here the client will call pop() whenever the client wants to retrieve an event from the server. The server will automatically acknowledge that the client has received this event.

Parameters
*pContextcontains the readers context to be used during construction of the reader
Returns
nQueueSyncReader
Exceptions
nIllegalArgumentExceptionif the context is null

◆ createTransactionalReader()

nQueueSyncTransactionReader * com::pcbsys::nirvana::client::nQueue::createTransactionalReader ( nQueueReaderContext pContext)

Creates a Synchronous Transaction queue reader.

This is similar in operation to the Synchronous model, except the server does not auto acknowledge the events, this enables the client to perform commit() or rollback() operations.

Parameters
*pContextcontains the readers context to be used during construction of the reader
Returns
nQueueSyncTransactionReader
Exceptions
nIllegalArgumentExceptionif the context is null

◆ getDetails()

nQueueDetails * com::pcbsys::nirvana::client::nQueue::getDetails ( )

This method returns the current queue details.

Returns
nQueueDetails to be examined
Exceptions
nSecurityExceptionClient is not authorized to perform the request
nChannelNotFoundExceptionThe Queue does not exist
nSessionNotConnectedExceptionClient is not currently connected to the server
nRequestTimedOutExceptionThe server did not respond within the client timeout
nUnexpectedResponseExceptionThe server responded with an unknown response
nSessionPausedExceptionThe session is currently paused

◆ getName()

std::string com::pcbsys::nirvana::client::nQueue::getName ( )

Gets the name of this queue.

Returns
a string specifying the name of this channel

◆ getQueueAttributes()

nChannelAttributes * com::pcbsys::nirvana::client::nQueue::getQueueAttributes ( )

This method will return the nChannelAttributes associated with the nQueue object.

Returns
the nChannelAttributes for the nQueue object

◆ purge() [1/2]

void com::pcbsys::nirvana::client::nQueue::purge ( )

Deletes all undelivered events from the queue.

Exceptions
nSecurityExceptionThe client is not authorized to perform this task
nChannelNotFoundExceptionThe Queue could not be found
nSessionNotConnectedExceptionClient is not currently connected to the server
nRequestTimedOutExceptionThe server did not respond within the timeout
nUnexpectedResponseExceptionThe server responded with an unknown response
nSessionPausedExceptionThe session is currently paused

◆ purge() [2/2]

void com::pcbsys::nirvana::client::nQueue::purge ( std::string &  selector)

Deletes all undelivered events from the queue.

Parameters
selectorPurges all events which match this filter
Exceptions
nSecurityExceptionThe client is not authorized to perform this task
nChannelNotFoundExceptionThe Queue could not be found
nSessionNotConnectedExceptionClient is not currently connected to the server
nRequestTimedOutExceptionThe server did not respond within the timeout
nUnexpectedResponseExceptionThe server responded with an unknown response
nSessionPausedExceptionThe session is currently paused

◆ push()

long com::pcbsys::nirvana::client::nQueue::push ( nConsumeEvent pEvent)

Pushes an event on to the queue.

Parameters
*pEventnConsumeEvent to push
Returns
an unique ID for the event on the queue
Exceptions
nIllegalArgumentExceptionIf the event is null
nSecurityExceptionIf your not authorized to publish to the queue
nRequestTimedOutExceptionIf the server failed to respond
nSessionNotConnectedExceptionClient is not currently connected to the server
nSessionPausedExceptionThe session is currently paused

◆ removeConnectionListener()

void com::pcbsys::nirvana::client::nQueue::removeConnectionListener ( nChannelConnectionListener pListener)

Removes the connection listener to this queue.

Parameters
*pListenerremove the listener
Exceptions
nRequestTimedOutExceptionif the request exceeded the timeout value
nSessionNotConnectedExceptionThe session is not currently connected to the server
nUnexpectedResponseExceptionReceived a response from the server for which we can not deal with, see the message for further information
nSessionPausedExceptionThe session is currently paused, please resume

◆ size()

int com::pcbsys::nirvana::client::nQueue::size ( )

Returns the number of events waiting in the queue.

Returns
int size of the queue