• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JMX Question about managing multiple JVMs  RSS feed

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 com.sun.management.jmxremote=xxxx.

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

Posts: 1210
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);


It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!