简体   繁体   中英

IBM MQ Queue JMS listeners receive msg by hostname or some Id

Is it possible to connect multiple JMS listeners to MQ queue and listeners get msgs based on Id (may be hostname).

While sending msgs (set this id?) and while subscribing we can setup subscriber with this id. Other side of broker will process message and on response they set this id so that specific listener will process the response.

MessageId/CorrId on each msg will work in send/receive pattern but that's not what I'm looking here as I'm using msg listener.

Gone through IBM MQ docs but not able to figure out this. Please give any doc reference/code example for solving this.

You can create your javax.jms.MessageConsumer with a "selector," for example, using javax.jms.Session.createConsumer(Destination, String) and then when you set your javax.jms.MessageListener implementation on this consumer it will only receive messages with property values which match that selector.

You could, therefore, set a property on your message named color when you send it and then your consumer could use a selector like color = 'red' . The consumer would only receive messages whose color property was the value red .

Message selectors (including syntax and matching semantics) are discussed in detail in the JavaDoc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM