javamqibm-mqwtx

How do I track replies to messages on WebSphere MQ?


I am using Websphere MQ as an input and output inside a Broker Application Flow. The flow also has Websphere Transformation Extender Maps in them.

I want use java to send a message with a unique identifier on the input queue and receive a reply on the output queue. I should be able to pick the message from the output queue using that unique identifier.

How can I do this?


Solution

  • The easy way to do this is to use the CorrelationID.

    The application that is processing requests will need to copy the MessageID to the CorrelationID of the reply message when responding. The requestor application specifies the CorrelationID as the message selector while receiving messages and provide the MessageID of the request message as the value for the selector.

    If you plan to use JMS, then it will be much simpler. Use the JMSMessageID and JMSCorrelationID properties and create a consumer with JMSCorrelationID as selector

    QueueReceiver queueReceiver = session.createReceiver(destination, "JMSCorrelationID='+ requestMsg.JMSMessageID +"'");