3.1.7.1.15 Peek Message
This event MUST be generated with the following arguments:
iQueueDesc: A reference to an OpenQueueDescriptor (section 3.1.1.16) ADM element instance that specifies the queue from which a message is peeked.
iTimeout (Optional): The amount of time to wait in seconds.
iCursor (Optional): A reference to a Cursor (section 3.2) ADM element instance that is used for the dequeue operation.
Return Values:
rStatus: A status code that can be one of the following:
MQ_OK (0x00000000)
MQ_ERROR_IO_TIMEOUT (0xC00E001B)
MQ_ERROR_MESSAGE_ALREADY_RECEIVED (0xC00E001D)
MQ_ERROR_QUEUE_NOT_AVAILABLE (0xC00E004B)
rMessage: A reference to the Message (section 3.1.1.12) ADM element instance that was peeked. This value is undefined if rStatus is not MQ_OK.
The queue manager MUST perform the following actions to process this event:
If iQueueDesc.QueueReference is NULL:
Set rStatus to MQ_ERROR_QUEUE_NOT_AVAILABLE (0xC00E004B).
Take no further action.
Set iQueue to iQueueDesc.QueueReference.
If the iTimeout argument is not specified, set it to Infinite.
Define iPosition as a MessagePosition (section 3.1.1.11) ADM element reference.
If the iCursor argument is supplied:
Generate the Get Message For Peek (section 3.2.7.2) event on iCursor.
If the rStatus return value from the Get Message For Peek (section 3.2.7.2) event is set to Succeeded:
Set rMessage to the returned rPosition.MessageReference.
Set rStatus to MQ_OK (0x00000000).
Take no further action.
Else, if the returned rStatus is set to AlreadyReceived:
Set rStatus to MQ_ERROR_MESSAGE_ALREADY_RECEIVED (0xC00E001D).
Take no further action.
Else, if the returned rStatus is set to Waiting:
Generate a Wait For New Message (section 3.1.7.3.1) event with the following inputs:
iQueueDesc := iQueueDesc
iTimeout := iTimeout
iDestructiveRead := False
iTag := NULL
iCursor := iCursor
If the rStatus return value from the Wait For New Message event is Success:
Set rMessage to the rMessagePosition.MessageReference returned from the Wait For New Message event.
Generate the Message Available (section 3.2.7.5) event on iCursor with the following inputs:
iMessagePosition := rMessagePosition returned from the Wait For New Message event.
Generate the Release Next Reader (section 3.1.7.3.7) event with the following inputs:
iReleaseOnQueue := iQueue.
Set rStatus to MQ_OK.
Take no further action.
Else:
Generate the Wait Time Expired (section 3.2.7.6) event on iCursor.
Set rStatus to the rStatus returned from the Wait For New Message event.
Take no further action.
Else, if the iCursor argument is not supplied:
Generate a Seek Available Message Position (section 3.1.7.3.2) event with the following inputs:
iInitialPosition := iQueue.MessagePositionList.Head.
iQueue := iQueue.
iPeekOperation := True
iSeekDirection := Forward
If rMessagePosition returned from the Seek Available Message Position event is equivalent to iQueue.MessagePositionList.End:
Generate a Wait For New Message event with the following inputs:
iQueueDesc := iQueueDesc
iTimeout := iTimeout
iDestructiveRead := False
iTag := NULL
iCursor := NULL
If the rStatus return value from the Wait For New Message event is Success:
Set rMessage to rMessagePosition.MessageReference returned from the Wait For New Message event.
Set rStatus to MQ_OK.
Take no further action.
Else:
Set rStatus to the rStatus returned from the Wait For New Message event.
Take no further action.
Else:
Set rMessage to the rMessagePosition.MessageReference returned from the Seek Available Message Position event.
Set rStatus to MQ_OK.
Take no further action.