Selecting messages from queues
To get a particular message from a queue, use the MsgId and CorrelId fields of the message descriptor. If you specify V2 of the MQMD, you also use the GroupId. (See Getting a particular message.)
A globally unique message identifier is ideally generated by the queue manager when a message is first put on a queue. Globally unique MsgIds improve serviceability because we can track messages across queue managers and locate messages in recovery logs for example. However, a WebSphere MQ application can specify a particular value for the message identifier, and although it is strongly recommended that application-generated MsgIds are unique identifiers, it is possible for an application to specify a non-unique MsgId.
You can use the correlation identifier in any way that you like. One intended use of this field is for applications to copy the message identifier of a request message into the CorrelId field of a reply message. Where possible use the CorrelId in preference to the MsgId if you want to associate an application-provided identity with a message. When retrieving a specific message on the distributed platforms, the queue manager is then optimized for retrieving messages by CorrelId (rather than by MsgId).
The group identifier is usually generated by the queue manager when the first message of a group is put onto a queue. The MsgSeqNumber field identifies the position of the message within the group and the Offset field identifies the segments within the message.
Where more than one message meets the combined selection criteria, the MsgDeliverySequence attribute of the queue determines whether messages are selected in FIFO (first in, first out) or priority order. When messages have equal priority, they are selected in FIFO order. For more information, see The order in which messages are retrieved from a queue.
For an example of an application that uses correlation identifiers, see The Credit Check sample.
Parent topic:
WebSphere MQ messages
fg10820_