Posts Tagged ‘JMX’

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

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

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

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

Read Full Post »