JMX Port dynamic allocation

允我心安 提交于 2019-12-07 07:56:43

问题


I have 16 Java processes with the same main method and arguments running on one machine. I wish to monitor these remotely thru JConsole.

Hard coding port numbers like -Dcom.sun.management.jmxremote.port=5000 won't work because these processes are using same configuration and they can't work with same port.

Is it possible for the JVM to select a different port dynamically for each of the 16 processes?


回答1:


Using RMI Connector might be the way as you may specify URL of your agent.

In case you'd need it, you may create RMI registry programatically using:

java.rmi.registry.LocateRegistry.createRegistry(port);

You may find following unrelated sample useful: Connecting Through Firewall Using JMX




回答2:


I don't think the oracle jvm supports anything like this. the only thing that might work is using the port "0", which enables "dynamic" port selection in some rmi related stuff.



来源:https://stackoverflow.com/questions/7112052/jmx-port-dynamic-allocation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!