Copyright © 2012-2013 firstname.lastname@example.org
Document Version 1.0
When you are familiar with JBoss, you should have known JMX-console. When you want to monitor you application deployed on JBoss, you might go with following step:
- wrapp the to be monitored property in a Mbean,
- register the MBean with JBoss' JMX sesrver
- check / manage the properties through JMX-Console
In such case, your will have to start your own JMX-server.
I will show how to use your own JMX-server, to monitor a standalone application which monitors the application's local time.
1. The MBean
The MBean interface exposes which methods are monitored by JMX.
This is the MBean implementation. The property "serverTime" will be updated every 5 seconds. We expect the upated serverTime will be shown to a JMX client when it connects to JXX-Server.
2. A JMX Agent
This is the main class of the program, we call it a JMX agent. It starts a JMX-Server, starts the MBean, and regist the MBean with the JMX-Server.
3. Configuration JMX access:
Create a "jmxremote.access" file:
Create a "jmxremote.password" file:
4. Run MyJMXAgent as Java application:
A JMX-Server is now running on localhost:1717, and you could use a JMX-client to connect to it.
5. Connect to JMX-Server with jconsole
Start jconsole an connect to MyMXAgent:
Check monitored property "serverTime":
Click "Refresh" button to get the updated "serverTime" :