IBM WebSphere MQ request/reply scenario

后端 未结 2 1052
粉色の甜心
粉色の甜心 2020-12-05 20:39

I\'m currently working on a project where I need to interface with an IBM system which communicates with the outside world through WebSphere MQ. I need to query the system i

2条回答
  •  囚心锁ツ
    2020-12-05 21:13

    It is common practice to use CorrelationId to relate request and response messages. It works this way:

    1) Let's assume there are two queues, a REQQ - request queue where messages are put asking another application, service application, to pick up and process and a RESPQ to which the service application puts replies.

    2) The requester application (let's call it as REQAPP) puts a request message (REQMSG) to request queue (REQQ). Before sending the message the REQAPP sets ReplyToQ property on the messages to RESPQ. When the request message is sent, the JMS provider updates the sent message with a unique MessageId. The requester application caches this unique MessageId for later use.

    3) On the other side of the world, the service application retrieves the REQMSG from REQQ, reads the MessageId and ReplyToQ property from that message, processes the request and prepares appropriate response message RESPMSG. It then sets the CorrelationId property of the RESPMSG to the MessageId read from the REQMSG and puts the reply to ReplyToQ.

    4) The requester application when reading replies, it uses the caches MessageId and sets selection criteria as below to read reply message

    GET MESSAGE FROM RESPQ WHERE RESPMSG.CORRELATIONID==REQMSG.MESSAGEID
    

    This selection criteria makes sure that correct response messages is retrieved. The key here is the service application must set the CorrelationId on the response message to the MessageId of request message.

    Although Queue is FIFO type, MQ implementation provides message delivery on a Priority basis where messages with high priority are delivered first or FIFO basis where message on top of the queue is delivered first. Messages can also be retrieved using selection criteria as explained in above example.

    Hope this helped

提交回复
热议问题