The Browsing WebSphere MQ Queues sample demonstrates how a message flow can browse messages that are on a queue, and retrieve the data from these messages without removing them from the queue. The sample examines the contents of the messages using browse, to determine whether to get the message from queue. Getting the message removes the message from the queue, but browse leaves the message on the queue.
The sample contains a single message flow called BrowseGet. The message flow browses a message on the input queue and then routes the message based on the value of the StaffNumber field. The message flow then removes the message from the queue, and puts the message to a second queue.
The BrowseGet message flow demonstrates the following tasks:
The following figure shows the BrowseGet message flow:
The MQInput node called MQBROWSE_IN reads the XML message from the MQBROWSE_IN queue. Because the Browse Only option is specified on this node, the message is not removed from the input queue.
The Route node called StaffNumber=2 runs the XPath expression:
$Body/Staff/StaffNumber="2"|Match
If the message does not contain a value of 2 for StaffNumber, the message flow processing stops, and the message remains on the input queue. If the message contains a value of 2 for StaffNumber, message flow processing continues to the next node.
The MQGet node called MQBROWSE_IN gets the message from the input queue. The Get by message ID property on the node is checked to ensure that it is the current message that is removed from the input queue.
The MQOutput node called MQBROWSE_OUT puts the message to the MQBROWSE_OUT queue.
The test messages used in the Browsing WebSphere MQ queues sample are simple XML messages that contain staff details for a company.
staffmsg1:
<Staff> <StaffNumber>1</StaffNumber> <NameInfo> <LastName>Smith</LastName> <FirstName>Jack</FirstName> </NameInfo> </Staff>
staffmsg2:
<Staff> <StaffNumber>2</StaffNumber> <NameInfo> <LastName>Doe</LastName> <FirstName>Jane</FirstName> </NameInfo> </Staff>