This class provides a Queue mechanism. More...
#include <nQueue.h>
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. More... | |
nQueueAsyncReader * | createAsyncReader (nQueueReaderContext *pContext) |
Creates an Asynchronous queue reader. More... | |
nQueueAsyncTransactionReader * | createAsyncTransactionalReader (nQueueReaderContext *pContext) |
Creates an Asynchronous Transactional queue reader. More... | |
nQueueSyncReader * | createReader (nQueueReaderContext *pContext) |
Creates a Synchronous queue reader. More... | |
nQueueSyncTransactionReader * | createTransactionalReader (nQueueReaderContext *pContext) |
Creates a Synchronous Transaction queue reader. More... | |
nQueueDetails * | getDetails () |
This method returns the current queue details. More... | |
std::string | getName () |
Gets the name of this queue. More... | |
nChannelAttributes * | getQueueAttributes () |
This method will return the nChannelAttributes associated with the nQueue object. More... | |
void | purge (std::string &selector) |
Deletes all undelivered events from the queue. More... | |
void | purge () |
Deletes all undelivered events from the queue. More... | |
long | push (nConsumeEvent *pEvent) |
Pushes an event on to the queue. More... | |
void | removeConnectionListener (nChannelConnectionListener *pListener) |
Removes the connection listener to this queue. More... | |
int | size () |
Returns the number of events waiting in the queue. More... | |
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. More... | |
nSession * | getSession () |
Returns the nSession used to create/find this channel. More... | |
void | updateProtobufDefinitions (const std::vector< ProtobufDescriptor * > &descriptors) |
Update the Protocol Buffer definition for the store. More... | |
Static Public Member Functions | |
static void | destroyReader (nQueueReader *pReader) |
This call will release any outstanding resources on the server and close the reader. More... | |
static void | destroyReaderLocally (nQueueReader *pReader) |
This call will close local reader resources but remain subscribed at the server Any future calls to this object will work unless destroyReader() is called. More... | |
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 |
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.
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.
*pListener | to add |
nRequestTimedOutException | if the request exceeded the timeout value |
nSessionNotConnectedException | The session is not currently connected to the server |
nUnexpectedResponseException | Received a response from the server for which we can not deal with, see the message for further information |
nIllegalArgumentException | Passed am illegal argument. This means the value passed is outside expected limits, or has already been set. |
nSessionPausedException | The session is currently paused, please resume |
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.
*pContext | contains the readers context to be used during construction of the reader |
nIllegalArgumentException | if the context is null or some non specified error is found |
nSecurityException | if the subject does not have the correct permissions |
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.
*pContext | contains the readers context to be used during construction of the reader |
nIllegalArgumentException | if the context is null or some non specified error is found |
nSecurityException | if the subject does not have the correct permissions |
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.
*pContext | contains the readers context to be used during construction of the reader |
nIllegalArgumentException | if the context is null |
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.
*pContext | contains the readers context to be used during construction of the reader |
nIllegalArgumentException | if the context is null |
|
static |
This call will release any outstanding resources on the server and close the reader.
Any future calls to this object will result in an nIllegalStateException being raised.
*pReader | The reader to close |
nUnexpectedResponseException | if the server returns a response that was not expected |
nSessionNotConnectedException | if the session is currently not connected to the server |
nRequestTimedOutException | if the request did not receive a response within the timeout period |
nSessionPausedException | The session is currently paused |
|
static |
This call will close local reader resources but remain subscribed at the server Any future calls to this object will work unless destroyReader() is called.
*pReader | The reader to close |
nUnexpectedResponseException | if the server returns a response that was not expected |
nSessionNotConnectedException | if the session is currently not connected to the server |
nRequestTimedOutException | if the request did not receive a response within the timeout period |
nQueueDetails* com::pcbsys::nirvana::client::nQueue::getDetails | ( | ) |
This method returns the current queue details.
nSecurityException | Client is not authorized to perform the request |
nChannelNotFoundException | The Queue does not exist |
nSessionNotConnectedException | Client is not currently connected to the server |
nRequestTimedOutException | The server did not respond within the client timeout |
nUnexpectedResponseException | The server responded with an unknown response |
nSessionPausedException | The session is currently paused |
std::string com::pcbsys::nirvana::client::nQueue::getName | ( | ) |
Gets the name of this queue.
nChannelAttributes* com::pcbsys::nirvana::client::nQueue::getQueueAttributes | ( | ) |
This method will return the nChannelAttributes associated with the nQueue object.
void com::pcbsys::nirvana::client::nQueue::purge | ( | std::string & | selector | ) |
Deletes all undelivered events from the queue.
selector | Purges all events which match this filter |
nSecurityException | The client is not authorized to perform this task |
nChannelNotFoundException | The Queue could not be found |
nSessionNotConnectedException | Client is not currently connected to the server |
nRequestTimedOutException | The server did not respond within the timeout |
nUnexpectedResponseException | The server responded with an unknown response |
nSessionPausedException | The session is currently paused |
void com::pcbsys::nirvana::client::nQueue::purge | ( | ) |
Deletes all undelivered events from the queue.
nSecurityException | The client is not authorized to perform this task |
nChannelNotFoundException | The Queue could not be found |
nSessionNotConnectedException | Client is not currently connected to the server |
nRequestTimedOutException | The server did not respond within the timeout |
nUnexpectedResponseException | The server responded with an unknown response |
nSessionPausedException | The session is currently paused |
long com::pcbsys::nirvana::client::nQueue::push | ( | nConsumeEvent * | pEvent | ) |
Pushes an event on to the queue.
*pEvent | nConsumeEvent to push |
nIllegalArgumentException | If the event is null |
nSecurityException | If your not authorized to publish to the queue |
nRequestTimedOutException | If the server failed to respond |
nSessionNotConnectedException | Client is not currently connected to the server |
nSessionPausedException | The session is currently paused |
void com::pcbsys::nirvana::client::nQueue::removeConnectionListener | ( | nChannelConnectionListener * | pListener | ) |
Removes the connection listener to this queue.
*pListener | remove the listener |
nRequestTimedOutException | if the request exceeded the timeout value |
nSessionNotConnectedException | The session is not currently connected to the server |
nUnexpectedResponseException | Received a response from the server for which we can not deal with, see the message for further information |
nSessionPausedException | The session is currently paused, please resume |
int com::pcbsys::nirvana::client::nQueue::size | ( | ) |
Returns the number of events waiting in the queue.