This week's book giveaway is in the Web Services forum.
We're giving away four copies of Microservices in Action and have Morgan Bruce & Paulo A. Pereira on-line!
See this thread for details.
Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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

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);


Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!