What are some of the best practices in designing a JMX MBean? Any examples of ones you feel are especially useful?
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.
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.
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.
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.
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):
toString()
output can be next to uselesstrim()
it to remove whitespace etc.)The above changes the emphasis from a bean simply exposed via JMX to something approaching a useable admin console.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With