Thứ Sáu, 28 tháng 3, 2008

Remote JMX, RMI, and JMXServiceURL

When using Remote JMX with RMI, one of the comma gotchas results from problems with the JMX connection server address string supplied to the JMX connector server and to the JMX connector client. This address string is encapsulated in the JMXServiceURL class and useful details about it are found in its Javadoc-generated documentation. This document tells us that JMXServiceURL represents an "address of a JMX API connector server" and that it needs to meet the format service:jmx:protocol:sap.

The Javadoc-generated documentation for the javax.management.remote package and for the javax.management.remote.rmi package are even more useful in understanding the substance of the JMX connector server address (JMXServiceURL).

The javax.management.remote package explains the JMX connector server address in greater detail and even offers an example of such an address for an RMI connector: service:jmx:rmi:///jndi/rmi://myhost:1099/myname where the emphasized text indicates your own host and port. This package's Javadoc description also informs us that the first rmi in the address specifies the RMI connector while the second rmi in the address specifies the RMI registry.

As you would expect, the Javadoc description for the RMI-specific package javax.management.remote.rmi has even more specific RMI details than does the more general javax.management.remote package. This documentation provides deep coverage of the many different ways that an RMI connection can be established and looked up.

I prefer to use a JMXServiceURL of the format service:jmx:rmi://<host>:<port>/jndi/rmi://<host>:<port>/jmxrmi or service:jmx:rmi:///jndi/rmi://<host>:<port>/jmxrmi for specifying my standard Remote JMX Connectors via RMI.

A nice pictorial representation of the JMX Connector Server address is available in the image at http://edong.net/2008v1/docs/jmx/jmx-proxy.png. This image shows which portion of the address makes up the RMI connector and which part makes up the RMI registry address. Monitor Your Applications with JConsole - Part 3 provides coverage of the connector server address using RMI. Chapter 9 ("Distributed Services and Connectors") of "JMX Accelerated Howto" covers the JMX Connector Server address in significant detail and provides several examples. The JMX Technology for Remote Management section of Getting Started with Java Management Extensions: Developing Management and Monitoring Solutions contains an example of using a JMX RMI Connector Server. Finally, the Remote Management lesson of the Java Management Extensions Trail of the Java Tutorials contains very useful background on using Remote JMX. The example code that comes with the JMX tutorial is especially useful.

Không có nhận xét nào:

Đăng nhận xét