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.
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”.
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With