This method implements message polling. It allows you to specify a time
for messages to arrive on a queue. Java™ implements a helper function for this.
The C code base, as it is non-threaded, must implement a
function in application layer code. The following example demonstrates
the
Wait method:
- Java
- Message polling uses the waitForMessage() method. This
command issues a getMessage() command to the remote queue
at regular intervals. As soon as a message that matches the supplied filter
becomes available, it is returned to the calling application:
qmgr.waitForMessage("RemoteQMgr",
"RemoteQueue",
filter,
null,
0,
60000);
The waitForMessage() method
polls the remote queue for the length of time specified in its final parameter.
The time is specified in milliseconds. Therefore, in the example, polling
lasts for 6 seconds. This blocks the thread on which the command is running
for 6 seconds, unless a message is returned earlier. Message polling works
on both local and remote queues. Note: Using this technique sends multiple
requests over the network.