activemq-artemisjolokia

ActiveMQ Artemis Jolokia returns Status "404"


I want to get the amount of messages I have in my ActiveMQ Artemis queue, but when I execute this command:

curl -v -H "Origin:http://IP:port" -u user:pass http://IP:Port/console/jolokia/read/org.apache.activemq.artemis:broker=0.0.0.0,component=addresses,address=123456,subcomponent=queues,routing-type=anycast,queue=123456/MessageCount

I get this error

"error":"javax.management.InstanceNotFoundException : org.apache.activemq.artemis:broker=0.0.0.0,component=addresses,address=123456,subcomponent=queues,routing-type=anycast,queue=123456","status":404

Do you know why? If I put this URL

http://IP:Port/console/jolokia/read/org.apache.activemq.artemis:broker=0.0.0.0,component=addresses,address=123456,subcomponent=queues,routing-type=anycast,queue=123456/MessageCount  

in a browser like Chrome it works but with curl it doesn't work.


Solution

  • The name of an queue's MBean follows this pattern:

    org.apache.activemq.artemis:broker="brokerName",component=addresses,address="addressName",subcomponent=queues,routing-type="routingType",queue="queueName"
    

    Note that the quotation marks are part of the MBean's name. Therefore you need to specify them in your curl command. Here's an example that works for me with the default broker:

    curl -v -H "Origin: http://localhost" -u myUser:myPass http://localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker=\"0.0.0.0\",component=addresses,address=\"DLQ\",subcomponent=queues,routing-type=\"anycast\",queue=\"DLQ\"/MessageCount
    

    Notice the quotation marks along with the proper escaping so it executes on the command-line. There is a similar (although simpler) example in the documentation.