File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Distributed Java and the fly likes JMX Question about managing multiple JVMs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JMX Question about managing multiple JVMs" Watch "JMX Question about managing multiple JVMs" New topic

JMX Question about managing multiple JVMs

michael modenese

Joined: Mar 22, 2006
Posts: 12
I am trying to manage multiple Java processes on serverside with JMX. I have AcitveMQ setup and I can specify in the activemq.xml config file:
<managementContext connectorPort="10120" rmiServerPort="10135" jmxDomainName="my-broker" connectorPath="/jmxrmione" />
so the registry ist startet at port 10120 and the serviceport is 10135. the "stub" ist exportet with the name jmxrmione. I can connect tot it with JConsole using:


Now I have a Java-Serverprocess and i really like to have it also manageable on Port 10120. So i could connect to it with the JConsole using the fill connection:


Now the questions are:

How can I specify the Name of the "Stub" for a Java-Process ? Default seems always to be rmijmx.
How can I set the ServicePort for JMX for that Java-Process ? The Registryport can be set with the property

I could live with if I have to use a different registry for every JVM just for the sake of JMX, (although it seems very strange since I would use different names for the exportet stub) but the arbirtary Port is really a pain.

Thank you for kind reply

Michael Modenese

Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 497
If rmiregistry is running on port 10120, then from each of your java server processes, create a connector server factory with different service URLs as shown below:

Server 1:

Server 2:

Configure ActiveMQ to use the same RMI registry port:

ActiveMQ can then be monitored at service:jmx:rmi:///jndi/rmi://localhost:10120/jmxactivemq.
The rmiServerPort is ActiveMQ JMX agent's preferred ServerSocket port. Unless you have firewall restrictions, it need not be specified - it'll use any free port.
michael modenese

Joined: Mar 22, 2006
Posts: 12
Thank you very much for your reply !!

It works exactly the way I needed to have it ! Since you mentioned the Firewall-Issue:

As said, to preset the "ServicePort" for ActiveMQ:

<managementContext createConnector="true" connectorPort="10120" rmiServerPort="10135" jmxDomainName="my-broker" connectorPath="/jmxrmiaq" />

Where 10120 is the Registry port and 10135 the ServicePort where the socketcommunication happens.

To do the same in Java-Code, the url-String for the JMXServiceURL needs to be something rather cryptic:

String url = "service:jmx:rmi://localhost:10136/jndi/rmi://localhost:10120/jmxapp1";
// original String without fixed ServicePort: String url = "service:jmx:rmi:///jndi/rmi://localhost:10120/jmxapp1";
JMXServiceURL serviceURL = new JMXServiceURL(url);
JMXConnectorServer server = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbs);
System.out.println("\nStarting monitored app @ " + url);


I agree. Here's the link:
subject: JMX Question about managing multiple JVMs