HornetQ is an open source, multi-protocol, high performance, and clustered messaging system. Don’t get this confused with Jboss Messaging though because they are different. By installing an Agent on your HornetQ application you will be able to use custom JMX measures to gather data on various measures such as Message Count, Consumer Count, Number of Pages, etc. on various Queues. If there are more complex operations that you need done then a custom plugin would probably be needed. This blog will detail the use of the custom JMX measures.

Assuming you have your HornetQ application instrumented correctly and it’s tied to a System Profile, edit the System Profile and select Measures. Let’s add a custom JMX measure. Be sure to select the appropriate Agent Group(s) that you want

Click on the JMX tab at the top of the configuration dialog box. This is where you will need to specify the domain of an ObjectName which is used to query Mbeans, enter the appropriate key property values, and then specify the name of the MBean attribute which is queried. You can enter this information in manually, but there is a much easier way. While still on the JMX tab click the Browse Metrics button. This will launch a separate Metric Browser dialog box allowing you to browse available JMX metrics. Click the Pick Agent button in the upper right and select your agent that is connected to your HornetQ instance. This will automatically load the appropriate agent group, mapping, and PID along with the available JMX metrics for you to browse from.

To get the Message Count and other measures for a particular queue I need to expand org.hornetq. I am interested in the DLQ and ExpireyQueue queues so I will expand those further and you will see that I can simply select the measure I want and then the key properties on the right are automatically filled in.

Click OK to exit out of the Metric Browser dialog box and then click the Add button to add the custom JMX measure. Be sure to set a threshold when appropriate. Repeat the steps for any other measures you wish to add.

As you can see below I have added measures and set thresholds on message count and number of pages for DLQ and ExpireyQueue. Another counter you might be interested in is consumer count; which indicates how many consumers are currently running. I don’t care about consumer count on my DQL and ExpireyQueue queues because there are no programs reading them. They are just “buckets” to hold messages that have expired or cannot be delivered.

I set a threshold count of 1 or higher on message count because this could indicate that messages aren’t being processed in a timely manner. Keep in mind that message count for some queues depending on your environment could be higher due to the sheer volume of messages along with other factors.

I set a threshold count of 1 or higher on number of pages because this could indicate that the queues memory quota is filled. Again, this will be different based on your HornetQ implementation and environment.

Conclusion

As you can see, it is relatively easy to use custom JMX queries to gather important metrics on the performance of your HornetQ implementation without the need for any custom plugin. Once you have the measures created that you are interested in, throw them onto a dashboard or set up thresholds and alerting!