Monday, March 3, 2008

Controlling JConsole's MBean ObjectName Presentation

I sometimes find myself learning something the hard way and then finding that it was already available online after I have figured it out. One case of this happened recently when I played with JConsole and my naming of my JMX MBeans. I noticed that the "type" property in each ObjectName of my MBeans was listed first no matter where it fell in the order of properties. The remainder of the ObjectName properties were listed in the order they appeared in the ObjectName. What this implies is that MBean developers should provide the list of properties in order so that they will appear together correctly in the JConsole hierarchical tree. It also demonstrates the importance of using "type" in MBean names so that the first level will be set with this value automatically.

Chapter 3 ("Using JConsole") of the Java SE Monitoring and Management Guide covers this in much greater detail in the section called "Constructing the MBean Tree."

This section outlines the same observations I made above and learned the hard way, but it also adds a way to control the order of the displayed properties in the tree from the command line. The system property -Dcom.sun.tools.jconsole.mbeans.keyPropertyList can be used to specify a list of property names. The order of the specified list will be the order of nested hierarchical levels in JConsole's MBeans tree.

I had planned to write a more extensive blog on the appropriate naming of one or more MBeans to appropriately take advantage of JConsole's assumptions. However, the article cited above covers this thoroughly, so this blog entry has turned into a pointer to that article.

No comments: