Invoking MBeans Programmatically

JConsole is just one way to use the JMX services that are exposed by the JVM. You can also build your own clients to consume JMX services. This is a handy way to write tools you can use to manage your applications.

To create a JMX client, you’ll need some libraries that can speak to the JMX interfaces. Fortunately, the jmx4r gem provides a Ruby wrapper for this Java-based protocol.

Install the jmx4r gem with the following command:

 $ ​​gem​​ ​​install​​ ​​jmx4r

Before using this gem, you’ll need to make sure a JRuby server is running.

 $ ​​ruby​​ ​​--manage​​ ​​-S​​ ​​bin/puma

Now you can connect to the JMX services in the JRuby process from the shell. Begin by starting an IRB session and requiring ...

Get Deploying with JRuby 9k now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.