Browsing messages on a queue
Use this information to find out about browsing messages on a queue using the MQGET call.
To use the MQGET call to browse the messages on a queue:- Call MQOPEN to open the queue for browsing, specifying the MQOO_BROWSE option.
- To browse the first message on the queue, call MQGET with the MQGMO_BROWSE_FIRST option. To find the message that we want, call MQGET repeatedly with the MQGMO_BROWSE_NEXT option to step through many messages.
We must set the MsgId and CorrelId fields of the MQMD structure to null after each MQGET call in order to see all messages.
- Call MQCLOSE to close the queue.
- The browse cursor
When you open (MQOPEN) a queue for browsing, the call establishes a browse cursor for use with MQGET calls that use one of the browse options. We can think of the browse cursor as a logical pointer that is positioned before the first message on the queue. - Browsing messages when the message length is unknown
- Removing a message that we have browsed
We can remove from the queue a message that we have already browsed provided that we have opened the queue for removing messages as well as for browsing. (We must specify one of the MQOO_INPUT_* options, as well as the MQOO_BROWSE option, on your MQOPEN call.) - Browsing messages in logical order
- Avoiding repeated delivery of browsed messages
By using certain open options and get-message options, we can mark messages as having been browsed so that they are not retrieved again by the current or other cooperating applications. Messages can be unmarked explicitly or automatically to make them available again for browsing.
Parent topic: Getting messages from a queue