Dynamic JMX Port Allocation

I have 16 Java processes with the same main method and arguments running on the same machine. I want to track them remotely through JConsole.

Hard-coding port numbers, such as -Dcom.sun.management.jmxremote.port=5000 , will not work because these processes use the same configuration and they cannot work with the same port.

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

+4
source share
2 answers

Using an RMI connector may be the way you can specify the URL of your agent.

If you need it, you can create an RMI registry using:

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

You can find the following unrelated example: Connecting through a firewall using JMX

+1
source

I don't think oracle jvm supports something like this. the only thing that can work is to use port "0", which allows "dynamic" port selection in some rmi-related things.

0
source

All Articles