Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I access a JMX MBeanServer running in the same VM?

For a simple Java library which performs operations in constant intervals I have implemented JMX management using MXBeans and it works as expected, I can query the status and set parameters, supend / resume the operations etc in JConsole.

Now I would like to create a web application - to display and control the library operation.

I don't know wether it is a good idea to use the samy JMX API also in the web application, so I need a way to access the MXBeans which are registered in the same VM using the platform MBean Server:

MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

I noticed that the MBeanServer has a queryMBeans method. Should I use this method to access the registered JMX API MXBeans? There is a different path, using JMXConnectorFactory, which requires protocol, host, and port information so that the client can access a remote JMX server.

like image 726
mjn Avatar asked Feb 03 '11 19:02

mjn


People also ask

How do I access JMX?

The JMX Console. When the JBoss Server is running, you can get a live view of the server by going to the JMX console application at http://localhost:8080/jmx-console. You should see something similar to Figure 1.1, “View of the JMX Management Console Web Application”.

How do I view JMX MBeans?

Run the jconsole tool from the command line. Once you start jconsole , it will display the list of local processes to be monitored as shown in Figure 2. Now, you can connect to the service. Once connected, select the MBeans tab so that you can list the MBeans and manage them as shown in Figure 3.

What is a JMX endpoint?

Java Management Extensions (JMX) provide a standard mechanism to monitor and manage applications. By default, Spring Boot exposes management endpoints as JMX MBeans under the org. springframework.


1 Answers

If you only want to access the MBeanServer in the same JVM, then ManagementFactory.getPlatformMBeanServer(); is the way to do it.

JMXConnectorFactory is for accessing remote MBeanServers (i.e. in a different JVM, and/or on a different host).

like image 147
skaffman Avatar answered Sep 26 '22 07:09

skaffman