0
votes

I'm trying to retrieve the queue size of a given queue using jolokia interface of ActiveMQ. My queue name is /some/queue and because of the slashes I can't get the API to work correctly.

Here's what I tried:

curl -XGET --user admin:admin "http://localhost:8161/api/jolokia/read/org.apache.activemq:brokerName=localhost,destinationName=/some/queue,destinationType=Queue,type=Broker/QueueSize" | python -m json.tool

curl -XGET --user admin:admin "http://localhost:8161/api/jolokia/read/org.apache.activemq:brokerName=localhost,destinationName=%2Fsome%2Fqueue,destinationType=Queue,type=Broker/QueueSize" | python -m json.tool

One with not encoded / and the other with encoded to %2F, both queries return javax.management.InstanceNotFoundException. When I try to retrieve other queues it works. When I do destinationName=* it lists my queue:

    "org.apache.activemq:brokerName=localhost,destinationName=/some/queue,destinationType=Queue,type=Broker": {
        "QueueSize": 0
    },

How should I encode / in jolokia queries?

1

1 Answers

1
votes

Found it, to escape / in jolokia queue names one has to use ! in front of slash (source https://jolokia.org/reference/html/protocol.html#escape-rules).

So the correct CURL for this is (in bash ! has to be escaped with \):

curl -XGET --user admin:admin "http://localhost:8161/api/jolokia/read/org.apache.activemq:brokerName=localhost,destinationName=\!/some\!/queue,destinationType=Queue,type=Broker/QueueSize" | python -m json.tool