The JMX technology provides a simple, standard way of managing monitoring resources such as applications, devices, services and jvm.

Using the JMX technology, a given resource is instrumented by one or more Java objects known as Managed Beans, or MBeans. These MBeans are registered in a core-managed object server, known as an MBean server.

Jconsole is a jvm monitoring tool based on jmx. It is basically a jmx client.

An MBean is a managed Java object, similar to a JavaBeans component, that follows the design patterns set forth in the JMX specification.

MBeans expose a management interface that consists of the following:

  • A set of readable or writable attributes, or both.
  • A set of invokable operations.
  • A self-description.
Client can connect using any protocol depending on the adapters.
Sample Mbean
//this is the interface for MBean
//name should end in MBean
public interface TestMBean { 
    public void test(); //operation
    public int add(int x, int y); //operation
    public String getName(); //getter to read the name attribute
    public int getCacheSize(); //getter to read the cache size attribute 
    public void setCacheSize(int size); //setter write the cache size attribute
//then we implement it
public class Test implements TestMBean { }
// The usage
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
ObjectName name = new ObjectName("type=Test"); 
Test mbean = new Test(); 
mbs.registerMBean(mbean, name);

If MBeans implement the interface NotificationEmitter or extend NotificationBroadcasterSupport then they can generate notifications and this can be seen in the JConsole.

Remote Management

the default protocol for connecting to an MBean connector server is RMI.

to enable an app for remote management we need:

java = 9999 = false = false com.example.Main

we can write our own jmx custom clients to connect to MBeans instead of using jconsole.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License