JMX : Some Introductory Notes

JMX (Java Management Extensions) is a J2SE technology which enables management and monitoring of Java applications. The basic idea is to implement a set of management objects and register the implementations to a platform server from where these implementations can be invoked either locally or remotely to the JVM using a set of connectors or adapters.
A management/instrumentation object is called an MBean (stands for Managed Bean). Once instantiated a MBean will be registered with a unique ObjectName with the platform MBeanServer. MBeanServer acts as a repository of MBeans enabling the creation, registering, accessing and removing of the MBeans. However MBeanServer does not persist the MBean information. So with a restart of the JVM you would loose all the MBeans in it. The MBeanServer is normally accessed through its MBeanServerConnection API which works both locally and remotely.

The management interface of an MBean would typically consist of [1]

  • Named and typed attributes that can be read/ written
  • Named and typed operations that can be invoked
  • Typed notifications that can be emitted by the MBean
For example say it is required to manage a thread pool parameters of one of your applications at runtime. With JMX it?€™s a matter of writing a MBean with logic related to setting and getting these parameters and registering it to the MBeanServer.
Now the next step is to expose these mbeans to the outside world so that remote clients can invoke these MBeans to manage your application. It can be done via various protocols implemented via protocol connectors and protocol adapters. A protocol connector basically expose MBeans as they are so that remote client sees the same interface (JMX RMI Connector is a good example). So basically the client or the remote management application should be enabled for JMX technology.
A protocol adapter (e.g: HTML, SNMP) adapt the results according to the protocol the client is expecting (e.g: for a browser-based client sends the results in HTML over HTTP).
Now that MBeans are properly exposed to the outside we need some clients to access these MBeans to manage our applications. There are basically two categories of clients available according to whether they use connectors or adapters.
JMX Clients use JMX APIs to connect to MBeanServer and invoke MBeans. Generally JMX Clients use a MBeanServerConnection to connect to the MBeanServer and invoke MBeans through it by providing the MBean ID (ObjectName) and required parameters. There are basically three types of JMX Clients.
Local JMX Client : A client that runs in the same JVM as the MBeanServer. These clients can also use MBeanServer API itself since they are running inside
the same JVM.
Agent : The agent is a local JMX Client which manages the MBeanServer itself. Remember that MBeanServer does not persist MBean information. So we can use an Agent to provide this logic which would encapsulate the MBeanServer with the additional functionality. So the Agent is responsible for initializing and managing the MBeanServer itself.
Remote JMX Client : Remote client is only different from that of a local client in that it needs to instantiate a Connector for connecting to a Connector server in order to get a MBeanServerConnection. And of course they would be running in a remote JVM as the name suggests.
Next type of client is the Management Clients which use protocol adapters to connect to MBeanServer. For these to work the respective adapter should be present and running in the JVM being managed. For example HTML adapter should be present in the JVM for a browser-based client to connect to it invoke MBeans. 

The diagram below summarizes the concepts described so far.

This concludes my quick notes on JMX. An extremely good read on main JMX concepts can be found at [2]. Also JMX learning trail at Oracle is a good starting point for getting good with JMX.

[1] http://docs.oracle.com/javase/6/docs/technotes/guides/jmx/overview/instrumentation.html#wp998816
[2] http://pub.admc.com/howtos/jmx/architecture-chapt.html

Reference: JMX : Some Introductory Notes from our JCG partner Buddhika Chamith at the Source Open blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


7 − = two



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close