aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JMX Question about managing multiple JVMs" Watch "JMX Question about managing multiple JVMs" New topic
Author

JMX Question about managing multiple JVMs

michael modenese
Greenhorn

Joined: Mar 22, 2006
Posts: 12
Hello
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>
<managementContext connectorPort="10120" rmiServerPort="10135" jmxDomainName="my-broker" connectorPath="/jmxrmione" />
</managementContext>
....
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:

service:jmx:rmi:///jndi/rmi://SERVERNAME:10120/jmxrmione

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:

service:jmx:rmi:///jndi/rmi://SERVERNAME:10120/jmxrmitwo

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





Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 475
    
    3
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
Greenhorn

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>
<managementContext createConnector="true" connectorPort="10120" rmiServerPort="10135" jmxDomainName="my-broker" connectorPath="/jmxrmiaq" />
</managementContext>

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);
server.start();


Michael







 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMX Question about managing multiple JVMs
 
Similar Threads
Connect JConsole to Websphere
JBoss JMX client
JNDI Port number issue while strating JBoss server 4.2.2.GA
JMX with Tomcat
Connecting JBoss with JMXConnectorFactory