How do I consume a specific message

 FAQ > JMS > How do I consume a specific message

If you want to consume messages in a different order, or consume specific messages at the head, middle or tail of the queue, you can

  • browse the messages using the QueueBrowser to find the JMSMessageID’s of the messages you want to consume
  • create a new consumer with a selector matching the ID(s) you want.

e.g. here is an example selector

JMSMessageID = 'abc'

Note that this is not a very efficient way of working with JMS (JMS is designed for consumers to be long lived objects working across many messageS), but it can be useful in certain situations.

Another option is just to use JMX directly to browse messages on a queue, process them and then delete them.

Apache, ActiveMQ, Apache ActiveMQ, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright © 2024, The Apache Software Foundation. Licensed under Apache License 2.0.