During ‘Part 1’ of this blog post, we saw that from Mule (or any other Java application), a JMX attribute exposed on a system can easily be read and re-exposed as a JMX attribute on your system. In this blog post, we show how this value can be monitored from MMC.
Let’s start off by explaining why this was required. In our system, messages were being placed on a queue at a rate of approximately 20 messages per second. These have to be consumed and processed immediately. Hence we wanted to monitor the queue size to know whether our system is keeping up with the rate of incoming messages, and as we said in the previous blog post, we already had MMC installed.
Let’s go straight to the action; first, let’s check that our JMX attribute is being exposed as expected. From MMC, hit the Servers tab, click on your server, and choose the JMX tab. From here, you can check all the exposed JMX attributes. The following image shows the custom Java class exposed with the ActiveMQ queue size value:
Now let’s define an alert. Hit Alerts at the top of the page and choose Alert Definitions on the left. Click New Alert. In the Type drop box, choose JMX Attribute. This opens a set of text boxes which you have to populate with information. Let’s say we want to fire a notification if our queue size exceeds 5000. Fill in the Name and Description with information that makes sense, choose your Server or Group from the drop down.
Next, browse for your MBean and choose the attribute you want to monitor, as shown in the following image:
Finally, choose the type of comparison that is required for this alert, and the value for the comparison. In our case, we want to throw an alert when the queue size exceeds 5000. For the comparison choose the symbol “>” and 5000 as a value. Also remember to populate the period. This is the frequency that MMC will poll the JMX attribute.
Any raised alerts will now be shown under the Alerts tab.