Search code examples
javaspringjmxmbeans

Spring JMX cascading/federating


I have a webapp running under Spring 3.2 and exposing a MBeanServer. Nevertheless this webapp can be run through different VM and so have multiple instance of JVM on different VM.

I want to modify MBeans on each MBeanServer instance, and I know there is a concept of cascading/federating JMX, but I didn't find anything to implement it using Spring.

So there is a way to federate spring MBeanServer easily? The main goal is to modify MBeans on each "frontend".


Solution

  • The JDMK (now available as OpenJDMK) implements MBean Cascading. Basically, this means that a series of individual MBeanServers (in different JVMs, but not exclusively) are "resurfaced" inside of one central MBeanServer. For example, you might have a GarbageCollector MXBean called java.lang:type=GarbageCollector,name=PS MarkSweep in 5 seperate JVMs (A..E). The central console would have its own instance and then you would also see 5 additional instances registered in the same MBeanServer named something like:

     - //JVM-A/java.lang:type=GarbageCollector,name=PS MarkSweep
     - ....
     - //JVM-E/java.lang:type=GarbageCollector,name=PS MarkSweep
    

    Here's an example screenshot of some cascades in my JConsole:

    enter image description here

    The documentation is available here. I also created a Maven friendly OpenJDMK build here, if that sort of thing is useful to you. (There's various different forked builds available on Sonatype Nexus too.)

    ** ===== UPDATE ===== **

    Yeah, sorry about that. Looks like the OpenJDMK web site has been neglected of recent.

    Here's a link to the User Guide, and a shortcut to the Cascading chapter. Here's a link to the Tutorial, and a shortcut to the Cascading.

    The tutorial has a decent selection of code samples.