Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
edited tags
Link
mjn
  • 36.7k
  • 30
  • 185
  • 392
Source Link
mjn
  • 36.7k
  • 30
  • 185
  • 392

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.