JMX and Jolokia
Reference: okminseok.blogspot.com, github.com/eugenp
What is JMX?
A technology that defines a complete architecture and a set of design patterns for monitoring and managing Java Applications
Think of it as an API that allows you to monitor the state of a running application and change its settings
It enables managing applications at runtime
It has been included as a standard feature since JDK 1.5
It was originally created to provide various features for application management
JMX Terminology
ManagedResource
A resource that is the target of management
MBean (Managed Bean)
A class instantiated in the JVM through dependency injection to represent a resource
Provides monitoring and management capabilities for Java applications
Provides an
interfacefor accessing and manipulating ManagedResources
MBean Server
A Java Class that manages MBeans
MBeans are registered with the MBean server, and the MBean server manages all remote managers that access resources
An element that acts as a mediator between MBeans, applications in the same JVM, and external systems
All interactions with MBeans are done through the MBean Server
Management Application
An application that manages applications built using JMX
Notification
A Java object that wraps events, alerts, and information generated by MBeans
Instrumentation
Resources managed by MBeans
Getting Started with JMX
To manage resources through JMX, you need to create Managed Beans called MBeans, and
Register the created MBeans with the
MBean ServerThe MBean Server acts as an agent that manages registered MBeans
The MBean server is launched internally within the implemented application
There are rules for implementing MBeans:
You must create a pair of interface and implementation,
The name of the MBean interface must end with "MBean"
If you only want to monitor exposed variables, you can omit the setter
ex)
ObjectNamehas a structure of domain and keyBy convention, the domain uses the Java package name to avoid naming conflicts
Keys can have multiple key=value pairs separated by commas
Jolokia and JMX
Generally, only Java code can directly access the JMX API, but there are adaptors that convert the JMX API to standard protocols
One of them is Jolokia, which converts the JMX API to HTTP
Jolokia is an agent that can be deployed in a JVM,
It exposes
MBeansthrough REST-likeHTTP endpoints,Making all information easily available to non-Java applications running on the same host
In a
standard JVM, it can be deployed as an agent,In
Java EE, it can be deployed as a WAR, OSGI, or Module agent
Last updated