JMXServiceUrls

what is the difference between

service:jmx:rmi://localhost:50000/osgi

and

service:jmx:rmi:///jndi/rmi://localhost:50000/osgi

If I want to manage remote hosts, which one should my Connector server use ?

I remember also seeing another url which has 2 host:port combinations. what is that all about ?

Thanks

Gavin

[359 byte] By [chihiroa] at [2007-11-26 20:11:52]
# 1

Gavin,

The first form is only valid as the address you supply when starting a ConnectorServer. The actual address that the ConnectorServer will have, as returned by ConnectorServer.getAddress() when you have started the ConnectorServer, is the so-called "encoded form" that is specified in the Javadoc for package javax.management.remote.rmi. This is the address that clients must use to connect. You can see an example at <http://weblogs.java.net/blog/emcmanus/archive/2006/12/securing_the_rm.html>. If you use this scheme, then you must somehow arrange for this address to get from the server to the client, for example by storing it in a file or a lookup service somewhere.

The second form uses the RMI registry at localhost:50000. Here the same address used to start the ConnectorServer and the actual address of the server are the same.

In this second form you can add a host:port after service:jmx:rmi:// if you want; they are ignored. The entry "osgi" in the RMI registry at localhost:50000 could actually be a ConnectorServer running on a different port, or even a different machine, and you could put these values in the address to reflect that.

Regards,

蒩monn McManus -- JMX Spec Lead -- http://weblogs.java.net/blog/emcmanus

emcmanusa at 2007-7-9 23:16:57 > top of Java-index,Core,Monitoring & Management...
# 2

蒩monn,

I believe I have a better idea of JMXServiceURLs.

Initially I'm going to stick with the second form.

I hope you could confirm that my understanding (described below) is correct:-

service:jmx: <protocol> : /// jndi/ <registry entry>

Protocol can be any item from the set { "rmi", "iiop", "jmxmp" }

Registry entry can be any item with the following example formats:

<registry type>: / <server> : <port> / path

e.g. ldap:/ localhost:4444 / cn=a,ou=b,rmi: / localhost:5555/foo

The registry name is quite flexible but I'm limiting them to only well known registries like LDAP and the default RMI.

I'm building a JMX client and packed with this understanding, my client can now prompt the user to enter only 7 variables:

protocol

registry-type

server

port

path

username

password

For comparison, JConsole allows one to even enter the generated STUB if one so wishes. Their textfield for URL is only prefilled with:

service:jmx

Thanks

Gavin

chihiroa at 2007-7-9 23:16:57 > top of Java-index,Core,Monitoring & Management...
# 3

Gavin,

Alas no, things are not so simple. The /jndi/ form is specific to RMI and RMI/IIOP. So for example the URL service:jmx:jmxmp:///jndi/whatever is not valid. So if the <protocol> is rmi or iiop in your example, then you can indeed specify a <registry type> and <server> and <port> and <path>; but if it is anything else then you can only specify a <path> (which is ignored in the case of JMXMP).

By the way you must use two slashes (//) with JNDI URLs, so rmi://localhost:5555/foo for example.

Regards,

蒩monn McManus -- JMX Spec Lead -- http://weblogs.java.net/blog/emcmanus

emcmanusa at 2007-7-9 23:16:57 > top of Java-index,Core,Monitoring & Management...