|
Websphere MQ Everyplace | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--examples.queuemanager.MessageWaiter
This class illustrates how to wait for a message to appear on a particular queue. It is intended as an example that can be modified to suit an individual developers requirements, rather than a reusable code snippet.
Note that although this method will wait for a message on a local queue residing upon a remote queue manager, it will do so by polling across the network. It will also require that the correct connection definitions are set up, and that the remote queue manager is responding.
Field Summary | |
static short[] |
version
|
Constructor Summary | |
MessageWaiter(MQeQueueManager queueManager,
java.lang.String queueQueueManagerName,
java.lang.String queueName)
Create a message waiter on a specified queue. |
Method Summary | |
MQeMsgObject |
getMessage(MQeFields filter)
Get a message from the receivers queue. |
MQeMsgObject |
waitForMessage(MQeFields filter,
long totalWaitTime,
long waitGranularity)
Wait for a message on the receivers queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static short[] version
Constructor Detail |
public MessageWaiter(MQeQueueManager queueManager, java.lang.String queueQueueManagerName, java.lang.String queueName)
queueManager
- The queue manager instance used as an access point to the MQe system.queueQueueManagerName
- The name of the queue manager upon which the local queue resides.queueName
- The name of the queue manager upon which the desired message resides.Method Detail |
public final MQeMsgObject getMessage(MQeFields filter) throws java.lang.Exception
To ignore a particular exception and keep retrying, catch the exception in this method and do not propagate it up the stack. The original implementation of MQeQueueManager.waitForMessage() can be duplicated by catching ALL exceptions and propagating none.
filter
- (com.ibm.mqe.MQeFields) a matching criteria for the message. May be null;
java.lang.Exception
public final MQeMsgObject waitForMessage(MQeFields filter, long totalWaitTime, long waitGranularity) throws java.lang.Exception
Any exception thrown while retreiving the message (except for message not found) will be thrown to the caller. This is not exactly the behaviour exhibited by the deprecated MQeQueueManager.waitForMessage(), which would continue trying until the time elapsed or a message was retreived. The original behaviour can be recreated by masking ALL exceptions in the MessageWaiter.getMessage() method.
filter
- a matching criteria for the message. May be nulltotalWaitTime
- the maximum amount of time to wait for a message.
java.lang.Exception
|
Websphere MQ Everyplace | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |