Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the characteristics of a well-designed JMX MBean

What are some of the best practices in designing a JMX MBean? Any examples of ones you feel are especially useful?

like image 905
McGovernTheory Avatar asked Mar 31 '09 13:03

McGovernTheory


People also ask

What is a JMX MBean?

An MBean is a managed Java object, similar to a JavaBeans component, that follows the design patterns set forth in the JMX specification. An MBean can represent a device, an application, or any resource that needs to be managed.

What is JMX specification?

The JMX specification defines the architecture, design patterns, APIs, and services in the Java programming language for management and monitoring of applications and networks. Using the JMX technology, a given resource is instrumented by one or more Java objects known as Managed Beans, or MBeans.

Which features are provided by Spring JMX?

Specifically, Spring's JMX support provides four core features: The automatic registration of any Spring bean as a JMX MBean. A flexible mechanism for controlling the management interface of your beans. The declarative exposure of MBeans over remote, JSR-160 connectors.

How many types of MBeans are there in JMX?

JMX defines four types of MBeans to support different instrumentation needs: Standard MBeans : These use a simple JavaBean style naming convention and a statically defined management interface. This is the most common type of MBean used by JBoss. Dynamic MBeans : These must implement the javax.


1 Answers

Return absolute counts instead of rates. e.g. return total number of db commits, rather than deriving a rate.

By doing this, your clients can monitor and derive rates themselves, over whatever time periods they require. Perhaps more importantly, this protects the clients from missing surges in rates if they only connect infrequently.

If you're using JMX beans primarily via the HTML interface, then there are several practises I follow. The below often means that your JMX bean should wrap an existing bean (as opposed to just JMX-exposing existing methods):

  1. output properly formatted strings representing returned objects. Getting a default toString() output can be next to useless
  2. capture and display exceptions. Otherwise you'll likely get a blank page and have to go to the log files to determine what went wrong
  3. if you're displaying different character sets, you may have to escape the output appropriately to prevent display problems (I ran into this with a JMX control displaying our Chinese data)
  4. inputs to exposed methods should be sanitised properly (e.g. if you input a id as part of an operation you may wish to trim() it to remove whitespace etc.)

The above changes the emphasis from a bean simply exposed via JMX to something approaching a useable admin console.

like image 93
Brian Agnew Avatar answered Sep 28 '22 04:09

Brian Agnew