One important item to keep track of is the number of messages going through each queue. This can be done with the activemq-admin tool. One of the most useful options of this tool is query which returns information about each queue. The general format is:
To get information about a particular queue use the -QQueue=queue_name; * works as a wildcard.
Due to our set up, we also need to set the rmi jmx details (port number, username, and password) via jmx flags: --jmxuser user_name --jmxpassword password_string --jmxurl service:jmx:rmi:///jndi/rmi://localhost:11223/jmxrmi
This script starts collecting stats such as the number of dequeued messages every 120secs into a file with the starting time stamp as part of the file name:
while [ $i -lt 30 ]
echo -n "date: " >> $file_out
date >> $file_out
../bin/activemq-admin query -QQueue=my.important.queue --jmxuser user_name --jmxpassword password_string --jmxurl service:jmx:rmi:///jndi/rmi://localhost:11223/jmxrmi >> $file_out
echo " " >> $file_out
Running activemq-admin against a queue will give a number of useful pieces of information about a queue such as the number of enqueued or dequeued messages.
We used the activemq-admin query command to diagnose a problem with message flow - more on that here.
For a way to find which queues have old messages and to list the number of old messages this post has more.