JMX

I’ve been working with the JVM either directly, or indirectly throughout my professional career. With that being said, I had never used JMX for anything. Recently I’ve been working with systems that use JMX to expose a number of pieces of functionality. The whole thing just really feels poorly suited to this purpose…

Problems

Obscure Integration Point

When trying to integrate with another system - whether internally, or belonging to a partner organization, saying that they need to integrate through JMX is just bad. First, the libraries available are a very, very small set:

Many of these have been abandoned for years and only offer limited functionality (or even just a thin facade).

Contrast that with using a REST-based approach! HTTP is been around for a little while, and its support in most popular programming languages is mature, robust, and actively developed.

Not NAT Friendly

When connecting to a JMX connector, the client hits a well defined host and port, only to have the server reply back with “I’m gonna let you finish and all, but connect back to me at some other address and a random non-privileged port”. This means if the server does not know what it’s externally addressable hostname is, the connection will fail. Worse, if the hostname is indeed different, it must be provided as a vm option! -Djava.rmi.server.hostname=MyPublicName.

This also implies that JMX doesn’t play well with SSH tunnels.

Arcane Arts

With a back-and-forth connection negotion, URIs that look like this: service:jmx:iiop:///jndi/iiop://host:port/weblogic.management.mbeanservers.runtime, and tools and documentation that appears to have not been touched since Sun existed, JMX is a pretty arcane art. Good luck finding help with it, and god help you if you need to get something up and running quickly.

A Better Integration Mechanism

REST, REST, REST! It’s extremely common, mature, and intuitive. There’s absolutely no reason why a complex system should have complex integration points - it’s just going to make pain for everyone involved.

So What Can I Use JMX For?

Well, some monitoring applications use it to varying degrees of success. I’d say it might be a good fit for developer manhole, or to expose some light amount of resource monitoring.

Even on those points however, better tool sets exist…

If you’re thinking about using JMX for something, think twice about it. If you’re thinking of using it for an integration point, please, just don’t.