More ActiveMQ admin URLs
In a previous post, we looked at querying ActiveMQ to get some details about queues. These details are very useful to see a detailed view of the system. Here are two more ways of looking into ActiveMQ - one more superficially and the other in detail.
Given that we run ActiveMQ in a production environment, we need to know that all of our applications are consuming messages and events from ActiveMQ as we'd expect. We can monitor the apps themselves for their throughput, but that depends on how many messages we have queued up for the app. Previously, we saw how to use activemq-admin query to find the number of messages enqueued, dequeued, dispatched, etc. However there are a couple of other, perhaps easier, ways to get some basic information about the number of messages in a queue. Using the web UI, you can get the number of messages programmatically just as you would browse yourself:
localhost:8161/admin/browse.jsp?JMSDestination=test123
Below is a way to get an XML list of the queue message ids. It is still under /demo/ in 5.8, but you'll need to enable demo in the jetty.xml file (look at jetty-demo.xml for the demo section):
localhost:8161/demo/queueBrowse/my_queue_name
This is a quick and easy way to get queue lengths and allows you to 'diff' against a previous check to see if the messages have moved much at all such as:
curl localhost:8161/demo/queueBrowse/my_queue_name > /tmp/id_list.now
sleep 30 # sleeps 30 seconds
mv /tmp/id_list.now /tmp/id_list.30s_old
curl localhost:8161/demo/queueBrowse/my_queue_name > /tmp/id_list.now
diff /tmp/id_list.30s_old /tmp/id_list.now # you can grep for newer entries (grep ^>) and count them
All easy stuff. In 5.9 and above, the urls have moved a little and you'll still need to enable as desired.
Viewing and consuming messages (and unsubscribing):
localhost:8161/demo/message/myTestQueue?type=Queue (5.8 and below)
localhost:8161/api/message/myTestQueue?type=Queue (5.9 and above)
Viewing xml message lists:
localhost:8161/demo/queueBrowse/myTestQueue(5.8 and below)
localhost:8161/admin/queueBrowse/myTestQueue(5.9 and above)
Don't forget that you can add the value
localhost:8161/demo/message/myTestQueue?type=Queue&clientId=myNewConsumer (5.8 and below)
and then unsubscribe that client when done (or it will time out eventually):
localhost:8161/demo/message/myTestQueue?clientId=myNewConsumer&action=unsubscribe
JMX information
ActiveMQ 5.8 added a nice feature in the form of Jolokia which gives easier access to JMX information. With ActiveMQ 5.8+, check out URLs like these:
http://localhost:8161/api/jolokia (really only good for the time stamp)
http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost
which shows you details such as the consumer count.
There's another example at the bottom of this page as well.
Given that we run ActiveMQ in a production environment, we need to know that all of our applications are consuming messages and events from ActiveMQ as we'd expect. We can monitor the apps themselves for their throughput, but that depends on how many messages we have queued up for the app. Previously, we saw how to use activemq-admin query to find the number of messages enqueued, dequeued, dispatched, etc. However there are a couple of other, perhaps easier, ways to get some basic information about the number of messages in a queue. Using the web UI, you can get the number of messages programmatically just as you would browse yourself:
localhost:8161/admin/browse.jsp?JMSDestination=test123
Below is a way to get an XML list of the queue message ids. It is still under /demo/ in 5.8, but you'll need to enable demo in the jetty.xml file (look at jetty-demo.xml for the demo section):
localhost:8161/demo/queueBrowse/my_queue_name
This is a quick and easy way to get queue lengths and allows you to 'diff' against a previous check to see if the messages have moved much at all such as:
curl localhost:8161/demo/queueBrowse/my_queue_name > /tmp/id_list.now
sleep 30 # sleeps 30 seconds
mv /tmp/id_list.now /tmp/id_list.30s_old
curl localhost:8161/demo/queueBrowse/my_queue_name > /tmp/id_list.now
diff /tmp/id_list.30s_old /tmp/id_list.now # you can grep for newer entries (grep ^>) and count them
All easy stuff. In 5.9 and above, the urls have moved a little and you'll still need to enable as desired.
Viewing and consuming messages (and unsubscribing):
localhost:8161/demo/message/myTestQueue?type=Queue (5.8 and below)
localhost:8161/api/message/myTestQueue?type=Queue (5.9 and above)
Viewing xml message lists:
localhost:8161/demo/queueBrowse/myTestQueue(5.8 and below)
localhost:8161/admin/queueBrowse/myTestQueue(5.9 and above)
Don't forget that you can add the value
&clientId=myConsumerId123
to the url to keep session state easily, as in:localhost:8161/demo/message/myTestQueue?type=Queue&clientId=myNewConsumer (5.8 and below)
and then unsubscribe that client when done (or it will time out eventually):
localhost:8161/demo/message/myTestQueue?clientId=myNewConsumer&action=unsubscribe
(5.8 and below) JMX information
ActiveMQ 5.8 added a nice feature in the form of Jolokia which gives easier access to JMX information. With ActiveMQ 5.8+, check out URLs like these:
http://localhost:8161/api/jolokia (really only good for the time stamp)
http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost
which shows you details such as the consumer count.
There's another example at the bottom of this page as well.
Comments
Post a Comment