Waiting for messages
If you want a program to wait until a message arrives on
a queue, specify the MQGMO_WAIT option in the Options
field
of the MQGMO structure.
Use the WaitInterval
field
of the MQGMO structure to specify the
maximum time (in milliseconds) that you want an MQGET call to wait
for a message to arrive on a queue.
If the message does not arrive within this time, the MQGET call completes with the MQRC_NO_MSG_AVAILABLE reason code.
You can specify an unlimited wait interval using the constant MQWI_UNLIMITED
in the WaitInterval
field.
However, events outside your control could cause your program to wait
for a long time, so use this constant with caution.
IMS applications
must not specify an unlimited wait interval because this would prevent
the
IMS system terminating. (When
IMS terminates,
it requires all dependent regions to end.) Instead,
IMS applications
can specify a finite wait interval; then, if the call completes without
retrieving a message after that interval, issue another MQGET call
with the wait option.
Options
field
of the MQGMO structure in MQGMO.- If the queue manager enters the quiescing state, and you used the MQGMO_FAIL_IF_QUIESCING option, the wait is canceled and the MQGET call completes with the MQRC_Q_MGR_QUIESCING reason code. Without this option, the call remains waiting.
- If the queue manager is forced to stop, or is canceled, the MQGET call completes with either the MQRC_Q_MGR_STOPPING or the MQRC_CONNECTION_BROKEN reason code.
- If the attributes of the queue (or a queue to which the queue name resolves) are changed so that get requests are now inhibited, the wait is canceled and the MQGET call completes with the MQRC_GET_INHIBITED reason code.
- If the attributes of the queue (or a queue to which the queue name resolves) are changed in such a way that the FORCE option is required, the wait is canceled and the MQGET call completes with the MQRC_OBJECT_CHANGED reason code.
For more information about the circumstances in which these actions occur, see MQGMO.