|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.safmq.MessageQueue
public class MessageQueue
This class represents a SAFMQ message queue by providing a facade in front of
the MQConnection
. This facade provides an interface to
queue operations such as enqueueing messages, retrieving messages, and scanning
the queue for messages with particular attributes.
Note: When a queue is no longer in use, a call to Close()
should be made so that resources on the server are released. Additionally,
when cursors are no longer needed, a call to CloseCursor()
should
be made.
Close()
,
CloseCursor(CursorHandle)
,
MQConnection
Constructor Summary | |
---|---|
MessageQueue(MQConnection con,
QueueHandle que)
Constructs the MessageQueue object, from an open
handle to a message queue. |
|
MessageQueue(java.lang.String queuename,
MQConnection con)
Constructs the MessageQueue object, from the queue's name
and a connection to the queue server. |
Method Summary | |
---|---|
int |
AdvanceCursor(CursorHandle cursorID)
Advances the cursor to the next message in the queue. |
int |
Close()
Closes the connection to the queue. |
int |
CloseCursor(CursorHandle cursorID)
Closes a cursor when it is no longer needed to access the queue. |
int |
Enqueue(QueueMessage msg)
Places a message on the queue. |
MQConnection |
getConnection()
|
int |
GetQueueStatistics(boolean includeStorageBytes,
boolean includeMessageBytes,
QueueStatistics stats)
Gets statistics about an open queue. |
int |
OpenCursor(CursorHandle cursorID)
Opens a cursor for sequential reading of the queue. |
int |
PeekCursor(boolean retrievebody,
CursorHandle cursorID,
QueueMessage msg)
Retrieves the message pointed to by cursorID . |
int |
PeekFront(boolean retrievebody,
int timeout,
QueueMessage msg)
Gathers the highest priority FIFO message present on the queue. |
int |
PeekID(boolean retrievebody,
UUID id,
int timeout,
QueueMessage msg)
Gathers the message identified by id in the message's
receipt id, set prior to the message having been enqueued (See:
Enqueue(QueueMessage) . |
int |
Retrieve(boolean retrievebody,
int timeout,
QueueMessage msg)
Retrieves the highest priority FIFO message present on the queue. |
int |
RetrieveCursor(boolean retrievebody,
CursorHandle cursorID,
QueueMessage msg)
Retrieves the message pointed to by cursorID . |
int |
RetrieveID(boolean retrievebody,
UUID id,
int timeout,
QueueMessage msg)
Retrieves the message identified by id in the message's
receipt id, set prior to the message having been enqueued (See:
Enqueue(QueueMessage) . |
int |
SeekID(UUID id,
int timeout,
CursorHandle cursorID)
Attempts to locate the messaged indicated by id . |
int |
TestCursor(CursorHandle cursorID)
Determines whether the cursor indicated by cursorID is still
a valid cursor, and has not been invalidated by other queue readers. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MessageQueue(java.lang.String queuename, MQConnection con) throws MQException
MessageQueue
object, from the queue's name
and a connection to the queue server. This method opens a reference to
the queue. In case of an error, an MQException
is thrown
reporting the status of the connection.
queuename
- The name of the queue to be openedcon
- A valid connection to a SAFMQ server
MQException
- In the case that OpenQueue reports an errorpublic MessageQueue(MQConnection con, QueueHandle que)
MessageQueue
object, from an open
handle to a message queue. This interface is useful when working
with a Temporary Queue, or already open queue.
con
- A valid connection to a SAFMQ server
MQException
- In the case that OpenQueue reports an errorMethod Detail |
---|
public int Close()
MQConnection.CloseQueue()
MQConnection.CloseQueue(QueueHandle) for details on errors
public int GetQueueStatistics(boolean includeStorageBytes, boolean includeMessageBytes, QueueStatistics stats)
stats
.
includeStorageBytes
- Causes server to calculate the number of bytes on diskincludeMessageBytes
- Causes the server to calculate the number of bytes in queue, may be less than bytes on diskstats
- Receives the statistics information.
public int Enqueue(QueueMessage msg)
msg
must have
been previously prepared before calling this method. Upon successful sending
of the message, the message id and message time stamp will be set by the server
and may be retrieved by a call to QueueMessage.getMessageID()
and QueueMessage.getTimeStamp()
respectively.
Note: Message responders will typically place the message id of the original message in the receipt id of the message being returned. This round-trip message identification is provided by SAFMQ as a method for coordinated two-way communications.
msg
- The message to be placed on the queue
MQConnection.Enqueue()
MQConnection.Enqueue(QueueHandle,QueueMessage) for details on errors
public int Retrieve(boolean retrievebody, int timeout, QueueMessage msg)
msg
.
Note: Retrieved messages are removed from the queue
retrievebody
- A flag indicating whether the body of the message should be retrievedtimeout
- The number of seconds to wait before returning, a value of zero (0) will
cause the method to return immediately if no messages are present on the queue,
a value of (-1) will cause the method to wait until a message is placed on the queue.msg
- Receives the contents of the message.
Safmq.EC_NOERROR
, otherwise
see MQConnection.Retrieve() for result codes.MQConnection.Retrieve(QueueHandle,boolean,int,QueueMessage)
public int RetrieveID(boolean retrievebody, UUID id, int timeout, QueueMessage msg)
id
in the message's
receipt id, set prior to the message having been enqueued (See:
Enqueue(QueueMessage)
. The results are placed in the object
msg
.
Note: Message responders will typically place the message id of the original message in the receipt id of the message being returned. This round-trip message identification is provided by SAFMQ as a method for coordinated two-way communications.
Note: Retrieved messages are removed from the queue.
retrievebody
- A flag indicating whether the body of the message should be retrievedid
- The UUID of the message to be retrieved.timeout
- The number of seconds to wait before returning, a value of zero (0) will
cause the method to return immediately if no messages are present on the queue,
a value of (-1) will cause the method to wait until a message is placed on the queue.msg
- Receives the contents of the message.
Safmq.EC_NOERROR
, otherwise
see MQConnection.RetrieveID() for result codes.MQConnection.Retrieve(QueueHandle,boolean,int,QueueMessage)
,
Enqueue(QueueMessage)
public int RetrieveCursor(boolean retrievebody, CursorHandle cursorID, QueueMessage msg)
cursorID
. The results
are placed in the object msg
.
Note: Retrieved messages are removed from the queue.
retrievebody
- A flag indicating whether the body of the message should be retrievedcursorID
- The cursor indicating the current position in the queue to be read frommsg
- Receives the contents of the message.
Safmq.EC_NOERROR
, otherwise
see MQConnection.Retrieve() for result codes.MQConnection.Retrieve(QueueHandle,boolean,int,QueueMessage)
public int PeekFront(boolean retrievebody, int timeout, QueueMessage msg)
msg
. Any errors from the operation are
returned on the stack. The message retrieved is not removed from the
queue and is available for reading by other queue readers.
retrievebody
- A flag indicating whether the body of the message should be retrievedtimeout
- The number of seconds to wait before returning, a value of zero (0) will
cause the method to return immediately if no messages are present on the queue,
a value of (-1) will cause the method to wait until a message is placed on the queue.msg
- Receives the contents of the message.
Safmq.EC_NOERROR
, otherwise
see MQConnection.Retrieve() for result codes.MQConnection.Retrieve(QueueHandle,boolean,int,QueueMessage)
public int PeekID(boolean retrievebody, UUID id, int timeout, QueueMessage msg)
id
in the message's
receipt id, set prior to the message having been enqueued (See:
Enqueue(QueueMessage)
. The results are placed in the object
msg
. The message retrieved is not removed from the
queue and is available for reading by other queue readers.
Note: Message responders will typically place the message id of the original message in the receipt id of the message being returned. This round-trip message identification is provided by SAFMQ as a method for coordinated two-way communications.
retrievebody
- A flag indicating whether the body of the message should be retrievedid
- The UUID of the message to be retrieved.timeout
- The number of seconds to wait before returning, a value of zero (0) will
cause the method to return immediately if no messages are present on the queue,
a value of (-1) will cause the method to wait until a message is placed on the queue.msg
- Receives the contents of the message.
Safmq.EC_NOERROR
, otherwise
see MQConnection.PeekID() for result codes.MQConnection.Retrieve(QueueHandle,boolean,int,QueueMessage)
,
Enqueue(QueueMessage)
public int PeekCursor(boolean retrievebody, CursorHandle cursorID, QueueMessage msg)
cursorID
. The results
are placed in the object msg
. The message retrieved is
not removed from the queue and is available for reading by other
queue readers.
Note: Retrieved messages are removed from the queue.
retrievebody
- A flag indicating whether the body of the message should be retrievedcursorID
- The cursor indicating the current position in the queue to be read frommsg
- Receives the contents of the message.
Safmq.EC_NOERROR
, otherwise
see MQConnection.PeekCursor()
for result codes.MQConnection.Retrieve(QueueHandle,boolean,int,QueueMessage)
public int OpenCursor(CursorHandle cursorID)
Cursors may be used to violate the priority FIFO nature of the queue
by scanning the queue and only retrieving messages which meet the
criteria of the reader. Cursor access is sequential when used in conjunction
with AdvanceCursor(CursorHandle)
, however specific messages may
be sought out by a call to SeekID(UUID,int,CursorHandle)
.
cursorID
- A previously allocated reference to a CursorHandle
which will receive the reference to the cursor.
Safmq.EC_NOERROR
upon success, otherwise see
MQConnection.OpenCursor(QueueHandle,CursorHandle)
for error codes.MQConnection.OpenCursor(QueueHandle,CursorHandle)
public int CloseCursor(CursorHandle cursorID)
CloseCursor()
and
should not be used again.
cursorID
- The cursor to be closed.
Safmq.EC_NOERROR
upon success, otherwise see
MQConnection.CloseCursor(QueueHandle,CursorHandle)
for error codes.MQConnection.CloseCursor(QueueHandle,CursorHandle)
public int AdvanceCursor(CursorHandle cursorID)
cursorID
- The cursor to be advanced.
Safmq.EC_NOERROR
upon success, otherwise see
MQConnection.AdvanceCursor(QueueHandle,CursorHandle)
for error codes.MQConnection.AdvanceCursor(QueueHandle,CursorHandle)
public int SeekID(UUID id, int timeout, CursorHandle cursorID)
id
. If the message
is successfully located, the cursor will point to the message identified
and the message may be retrieved there after.
id
- The receipt UUID of the message to be locatedtimeout
- The maximum number of seconds the call should be allowed
before resulting in a "timeout".cursorID
- The cursor which should be be assigned the position
of the message indicated by id
Safmq.EC_NOERROR
upon success, otherwise see
MQConnection.SeekID(QueueHandle,UUID,int,CursorHandle)
for error codes.MQConnection.SeekID(QueueHandle,UUID,int,CursorHandle)
public int TestCursor(CursorHandle cursorID)
cursorID
is still
a valid cursor, and has not been invalidated by other queue readers.
cursorID
- The cursor which should be be evaluated
Safmq.EC_NOERROR
upon success, otherwise see
MQConnection.TestCursor(QueueHandle,CursorHandle)
for error codes.MQConnection.TestCursor(QueueHandle,CursorHandle)
public MQConnection getConnection()
|
Copyright Matthew J. Battey, 2004-2010; Powered By: |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |