jmsjmxactivemq-artemisjolokia

Is it possible to get a single message from ActiveMQ Artemis through Jolokia JMX?


I try to get a single message from Artemis through Jolokia JMX but can't find a way to filter for JMSMessageID.

Broker version: Red Hat AMQ 7.11.7

My best attempt is currently:

https://broker/console/jolokia/exec/org.apache.activemq.artemis:broker=!%22amq-broker!%22,component=addresses,address=!%22ExpiryQueue!%22,subcomponent=queues,routing-type=!%22anycast!%22,queue=!%22ExpiryQueue!%22/browse(java.lang.String)/JMSmessageID=!%2215232235223!%22

It calls the browse(String filter) method on QueueControl, with the argument JMSmessageID="15232235223" but the filter does not work. When I execute this request, I just get all messages of the queue.

When I left out the double quotes around the message ID, I get no results.

I read in another answer that filtering for message headers is not possible (only for properties), which sounds weird.

However, any suggestions how to get a single message by message ID? Thanks


Solution

  • There's a few things to keep in mind here...

    1. The "message ID" that you see in the web console is really a way for the broker itself to track the message. It is subject to change under certain circumstances so it's not valid to use as a unique message identifier from a client application. If you're using a JMS client then the JMSMessageID should suffice for that. This is represented as "user ID" in the web console.
    2. Using JMSMessageID in a query would work if you were using a JMS client. However, the ActiveMQ Artemis web console doesn't use a JMS client when browsing messages. It simply uses the Core API. Therefore, you need to use a core filter expression, namely AMQUserID.
    3. JMSMmessageID requires starting with ID: as noted in the JavaDoc.
    4. The Core filter syntax uses the same SLQ 92 syntax as JMS selectors. This syntax does not enclose string literals in double quotes (i.e. "). You should use single quotes (i.e. ') instead. As noted in the relevant JavaDoc:

      A string literal is enclosed in single quotes...

    Putting this all together...Something like this should work for you:

    https://broker/console/jolokia/exec/org.apache.activemq.artemis:broker=!%22amq-broker!%22,component=addresses,address=!%22ExpiryQueue!%22,subcomponent=queues,routing-type=!%22anycast!%22,queue=!%22ExpiryQueue!%22/browse(java.lang.String)/AMQUserID='ID:8dfdf33e-bc84-11ef-9ea4-3ce1a1d12939'