Jolokia is usually bundled in with a number of Red Hat products in order to expose JMX statistics over HTTP. If you are an authenticated user, then you are able to query these statistics.
We will take the example of using the ActiveMQ 5.x libs (Red Hat Jboss ActiveMQ 6). When starting the ActiveMQ locally we get the log output:
Note that the log file advertises that Jolokia is available: ActiveMQ Jolokia REST API available at http://0.0.0.0:8161/api/jolokia/
Using this endpoint we can List all MBeans
And Get Broker Attributes:
The output is as follows:
From performing the above we can see which queues are available, and then query them with the following curl
using either GET:
or POST:
Which gives the result:
And for one particular attribute:
GET:
or POST:
With Result:
Now using Groovy
Let’s say we want to get some statistics for each queue, and display the results in an ASCII table…
The resulting output being: