Actuator JMX MBeans and JConsole

Chandra Sharma
3 min readJun 8, 2021

--

Spring Boot Actuator JMX MBeans With Jconsole
Spring Boot Actuator JMX MBeans With Jconsole by Chandra Sharma

Spring Boot supports production grade features by adding Actuators Dependency.

Here is the dependency we need to add to get all the exciting production grade features:

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>

Spring Boot Actuator Endpoint Types

Actuator Endpoint Types
Actuator Endpoint Types

We have two types of endpoints exposed by Spring Boot Actuator — HTTP & JMX.

By default, only Health and Info endpoints are enabled as HTTP Endpoints. Below is the table for your reference:

Actuator Endpoints Exposure
Actuator Endpoints Exposure

For this story, we are interested in the JMX MBeans exposed by Actuator.

What is JMX?

As stated in wikipedia:

Java Management Extensions (JMX) is a Java technology that supplies tools for managing and monitoring applications, system objects, devices (such as printers) and service-oriented networks. Those resources are represented by objects called MBeans.

Now, we know what is JMX, let’s move on to JConsole Part.

JConsole

JConsole is a JMX compliant monitoring and management tool. It allows you to connect to a remote Java application or JVM and monitor it. JConsole provides a simple Graphical User Interface (GUI) with some limited but important features that make it easy to monitor your Java application.

JConsole comes bundled with JDK setup and if you set the classpath for Java correctly, then it is just a matter of typing “jconsole” in the command prompt.

JConsole Window
JConsole Window listing the Java Processes

Learn more about JConsole in the below link:

Enabling JMX Endpoints

By default, JMX endpoints are not enabled. It can be turned on by setting the following configuration property.

spring.jmx.enabled = true

Where to find the Spring Boot Actuator Endpoints in JConsole?

Spring Boot exposes management endpoints as JMX MBeans under the org.springframework.boot domain by default. As highlighted in the below screenshot under the MBeans tab.

Note: You need to run the Spring Boot Application with Actuator Endpoint Dependency added and JMX enabled to make the process visible in the JConsole

JConsole MBeans Tab showing Actuator JMX Endpoints
JConsole MBeans Tab showing Actuator JMX Endpoints under org.springframework.boot domain

If you can expand the domain, all the MBeans will be visible as shown in the below screenshot. All you have to do is to select the bean and expand to see the operations available. “Health” is shown for reference.

JConsole showing Health Endpoint
JConsole showing Health Endpoint

Similarly, we can monitor and manage all the beans exposed by Actuator using free to use tool JConsole.

You can find the source for HelloSpringBootActuator in Tekgainers Github Repo.

You can watch my detailed video on Spring Boot Actuator explaining all the concepts and JConsole Hands-on.

Happy Reading :)

--

--

Chandra Sharma

I am a technology explorer who loves to read, hands-on and share the knowledge gained.