Relying on a standard JMX framework

The goal of this weblog entry is to detail how the Java JMX management framework can be leveraged when developing applications using Netbeans.

It is difficult to write about Java development outside of the context of an IDE. The way a Java library is used or understood is greatly influenced by the IDE used.
Using the IDE for writing, executing and debugging code is fine, but today we expect more than that. We want an IDE to help us realize the main use cases implied by the technologies we are using.

Among other tools, the Netbeans 5.0 beta release provides tools centered around Swing, XML, Web Services, and JMX API (you can download the JMX module from the beta update center). If you are not yet familiar with these features (including very cool Swing, CVS and J2EE support, among others), you should have a quick look at Roman Strobl's presentation.

Before we start, if you feel that a refresher is needed, have a look at the following excellent JMX API, JConsole and JDK 5 Management and Monitoring articles.

Something that can appear a little confusing when you are trying to find out where the borders of JMX technology are, is the coexistence of the JMX library and the JMX instrumentation of the JVM. You will in fact discover that ignoring this distinction and taking a global approach will make the use of JMX technology much more simple and powerful.

A brief history of JMX technology
In the old days of JMX, everyone who wanted to register MBeans had to create their own MBeanServer, then create and start some kind of non-standard remote access.  A step toward better interoperability was achieved by the introduction of standard RMI access. But still people were not able to rely on a standard "management framework". People had to create multiple paths to access their management. This situation lead to a kind of "management divide".
Java 2 Platform, Standard Edition (J2SE) 5 introduced a new and standard management platform.  The JMX developer can now rely on this management platform to deploy their management. An MBeanServer linked to a fully configurable RMI ConnectorServer are present on any JVM. If you want management you can get going with straight away, just use them!

As an example, management consoles (such as JConsole) rely increasingly on the existence of this standard framework. Deploying your MBeans in this framework will make them accessible from a wide range of JMX managers.

By relying on the Java management platform, you will greatly simplify the way you use JMX. In turn, if your IDE uses it, developing a JMX application should become a child's play... This is what we are going to see.

The Netbeans JMX module relies on the standard management framework. It makes use of the platform MBeanServer when:
  • Generating a JMX Agent. The JMX Agent is a Platform MBeanServer wrapper that allows you to instantiate, name and register your MBeans
  • Generating a JUnit JMX Test. Such tests allow you to activate MBean attributes and operations without dealing with the framework. The MBean under test is automatically registered in this MBeanServer.  At the end of a test session, the MBeanServer is cleaned from the MBean references.
==> During your JMX instrumentation coding and testing phase, you can rely on the presence of the platform MBeanServer.

The Netbeans JMX module makes use of the platform remote RMI access:
  • At execution time: The application under development is automatically launched with the RMI access enabled.
  • At debugging time: The application under debug is automatically launched with the RMI access enabled.
==> During the execution and debugging phases, again, you can rely on the presence of the remote RMI access.

Having your application ready to receive remote management requests is fine, but what about the manager layer? How do JMX managers / consoles enter the scene?
  • If you are not developing a full JMX Manager, you can rely on the JConsole generic management console. It will automatically connect to the running application, allowing visualization of the JVM state and interaction with MBeans.
  • If you are developing a JMX Manager, a JMX URL Editor helps you construct a reference to the remote RMI access.
==> Again, JMX clients will benefit from the existence of this framework.

I said that it's child's play... To help you, I have written a tutorial on how to start a JMX enabled Java application and how to connect to it.
The tutorial shows how the complexity of client / server application development can be reduced when handled directly from inside the IDE.
I recommend that you work through the tutorial. If you think that parts are still too complex, please let me know and we'll find an answer together to improve it.

If you want more details about how to add JMX to your application, you can work through another tutorial that shows you how to develop an MBean, test it, register it and interact with it at runtime.

To conclude, choosing to rely on this standard framework orientates the way you use JMX. One advantage of choosing it is that it will help you build your overall application management system. Making consistent choices will result in a coherent manageability application management solution.
 
Comments:

Hi, thnx for the tutorial it was very informative and easy to follow. I have a quick question. When i start the jconsole, there have to be an mbeanserver running(or an agent) to connect and see all the mbeans. Once i connect i see all these other mbeans like memory,logger9builtin mbeans) and all. Can i(why cant i) launch the jconsole and with out running my agent and still connect and see these built in mbeans? -Anil

Posted by Anil Jacob on March 22, 2006 at 05:29 PM GMT+02:00 #

JeanFrancois Denise,

If you could cross link this entry (http://blogs.sun.com/roller/page/bloggerkedar?entry=tech_tip_demonstrating_jmx_mbeans) it will be useful for JMX, NetBeans and GlassFish ... Regards, Kedar

Posted by Kedar Mhaswade on April 06, 2006 at 11:39 AM GMT+02:00 #

Hi,
My working environment does not allow NetbeansIDE to contact update center (not even via proxy).

If you can provide me with an URL for nbm file of jmx module, I can download it elsewhere and copy to my box. Thanks in advance for your help.

I'm running NB6.0M10 (fyi)

Posted by Elisha Ebenezer on August 21, 2007 at 06:41 AM GMT+02:00 #

this is cool, this is what we want dude......

Posted by links london on November 26, 2009 at 08:38 PM GMT+02:00 #

Post a Comment:
  • HTML Syntax: NOT allowed
About

jeanfrancoisdenise

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today