com.pcbsys.nirvana.client.nQueue Class Reference

This class provides a Queue mechanism. More...

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

Public Member Functions

void addConnectionListener (nChannelConnectionListener listener)
 Adds a nChannelConnectionListener to this queue so that when new connections are made to this queue the listener is notified More...
 
nQueueAsyncReader createAsyncReader (nQueueReaderContext context)
 Creates an Asynchronous queue reader. More...
 
nQueueAsyncTransactionReader createAsyncTransactionalReader (nQueueReaderContext context)
 Creates an Asynchronous Transactional queue reader. More...
 
nQueueSyncFragmentReader createFragmentReader (nQueueReaderContext context)
 Creates a Synchronous queue reader that supports event fragments. More...
 
nQueueSyncReader createReader (nQueueReaderContext context)
 Creates a Synchronous queue reader. More...
 
nQueueSyncTransactionFragmentReader createTransactionalFragmentReader (nQueueReaderContext context)
 Creates a Synchronous Transaction queue reader that supports event fragments. More...
 
nQueueSyncTransactionReader createTransactionalReader (nQueueReaderContext context)
 Creates a Synchronous Transaction queue reader. More...
 
nQueueDetails getDetails ()
 Provides additional information about this queue object More...
 
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 ()
 Deletes all undelivered events from the queue. More...
 
void purge (string selector)
 Deletes all undelivered events from the queue. More...
 
long push (nConsumeEvent e)
 Pushes an event on to the queue. More...
 
void removeConnectionListener (nChannelConnectionListener listener)
 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 object that this channel belongs to More...
 
void updateProtobufDefinitions (byte[][] descriptors)
 Sets the protobuf descriptors for this channel. More...
 

Static Public Member Functions

static void destroyReader (nQueueReader reader)
 This call will release any outstanding resources on the server and close the reader. More...
 
static void destroyReaderLocally (nQueueReader reader)
 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...
 

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. /para> 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. /para> 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

void com.pcbsys.nirvana.client.nQueue.addConnectionListener ( nChannelConnectionListener  listener)

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

Parameters
listenerto 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
nQueueAsyncReader com.pcbsys.nirvana.client.nQueue.createAsyncReader ( nQueueReaderContext  context)

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
contextcontains 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
nQueueAsyncTransactionReader com.pcbsys.nirvana.client.nQueue.createAsyncTransactionalReader ( nQueueReaderContext  context)

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
contextcontains 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
nQueueSyncFragmentReader com.pcbsys.nirvana.client.nQueue.createFragmentReader ( nQueueReaderContext  context)

Creates a Synchronous queue reader that supports event fragments.

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
contextcontains the readers context to be used during construction of the reader
Returns
nQueueSyncReader
Exceptions
nIllegalArgumentExceptionif the context is null
nQueueSyncReader com.pcbsys.nirvana.client.nQueue.createReader ( nQueueReaderContext  context)

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
contextcontains the readers context to be used during construction of the reader
Returns
nQueueSyncReader
Exceptions
nIllegalArgumentExceptionif the context is null
nQueueSyncTransactionFragmentReader com.pcbsys.nirvana.client.nQueue.createTransactionalFragmentReader ( nQueueReaderContext  context)

Creates a Synchronous Transaction queue reader that supports event fragments.

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
contextcontains the readers context to be used during construction of the reader
Returns
nQueueSyncTransactionReader
Exceptions
nIllegalArgumentExceptionif the context is null
nQueueSyncTransactionReader com.pcbsys.nirvana.client.nQueue.createTransactionalReader ( nQueueReaderContext  context)

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
contextcontains the readers context to be used during construction of the reader
Returns
nQueueSyncTransactionReader
Exceptions
nIllegalArgumentExceptionif the context is null
static void com.pcbsys.nirvana.client.nQueue.destroyReader ( nQueueReader  reader)
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.

Parameters
readerThe reader to close
Exceptions
nUnexpectedResponseExceptionif the server returns a response that was not expected
nSessionNotConnectedExceptionif the session is currently not connected to the server
nRequestTimedOutExceptionif the request did not receive a response within the timeout period
nSessionPausedExceptionThe session is currently paused
static void com.pcbsys.nirvana.client.nQueue.destroyReaderLocally ( nQueueReader  reader)
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

Parameters
readerThe reader to close
Exceptions
nUnexpectedResponseExceptionif the server returns a response that was not expected
nSessionNotConnectedExceptionif the session is currently not connected to the server
nRequestTimedOutExceptionif the request did not receive a response within the timeout period
nQueueDetails com.pcbsys.nirvana.client.nQueue.getDetails ( )

Provides additional information about this queue object

Returns
a nQueueDetails object which can be queried to provide additional information about this queue object.
string com.pcbsys.nirvana.client.nQueue.getName ( )

Gets the name of this queue.

Returns
a string specifying the name of this channel
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
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
void com.pcbsys.nirvana.client.nQueue.purge ( 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
long com.pcbsys.nirvana.client.nQueue.push ( nConsumeEvent  e)

Pushes an event on to the queue.

Parameters
enConsumeEvent 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 responded
nSessionNotConnectedExceptionClient is not currently connected to the server
nSessionPausedExceptionThe session is currently paused
void com.pcbsys.nirvana.client.nQueue.removeConnectionListener ( nChannelConnectionListener  listener)

Removes the connection listener to this queue

Parameters
listenerremove 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
int com.pcbsys.nirvana.client.nQueue.size ( )

Returns the number of events waiting in the queue.

Returns
int size of the queue