ibm-messaging / mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
Apache License 2.0
79 stars 41 forks source link

Retrieving messages from queue that matches an ID in the body #180

Closed kandukurivarun closed 6 months ago

kandukurivarun commented 6 months ago

Hi,

I am completely new with MQ's and I have a requirement to post a message in one queue and get the response in another queue. So far I am able to insert the message into queue-1 and get all the messages from queue-2. But my requirement is to get response from queue-2 only for the message that I inserted queue-1. These queues are shared queues and there are multiple consumers who will be pulling messages from queue-2. So my requirement is to fetch the response for message I inserted and leave everything within the queue.

I tried using MQGMO_SYNCPOINT in the get message options but it is still removing all messafes from queue-2. How can I specifically filter/select a message from queue and commit only that message.

Any inputs are appreciated.

ibmmqmet commented 6 months ago

The usual pattern for getting a specific reply message is to use the MessageId or CorrelId as a selector, depending on how the responding application is processing its request. The MatchOptions says which field to look for.

See https://github.com/ibm-messaging/mq-dev-patterns/blob/master/Node.js/basicrequest.js as an example