|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Managing the Unmanaged
Using JMX To Manage Your Preexisting JAVA Applications
By: Gil Salu; Greg DeMelo
May. 5, 2004 12:00 AM
Hardly anyone ever thinks about application management frameworks until the application is running in a production environment and the application needs managing. The use of Java and J2EE has allowed business code to be written at lightning fast speed and application management is normally considered only as an afterthought. Without the convenience of an application server to start/stop and change various settings, these applications become monsters to administer and manage. Although JMX is a technology that is most often thought of for J2EE integration, JMX can also be used to quickly provide a management console for any well-designed standalone Java application with only minor refactoring efforts. Sample SituationA widget manufacturing company has a custom-built application that controls the rate of widget production. Every 10 seconds a new widget is produced. Most of the time the manufacturing line gets ahead of schedule and the workers sit idly by. Sometimes the line gets behind schedule at which point any onlooker would be reminded of Lucy and Ethel at the candy factory. When workers want to go to lunch, the application that controls everything must be killed. When lunch is over, the application must be manually restarted, a very lengthy process. Overall the production of widgets has become very inefficient.Seeing these inefficiencies the business managers decide that they would like a way to change the rate at which widgets are produced. When the line is ahead of schedule, they'd like to fill capacity. When the line is slow and widgets are backing up, they would like to slow things down. Instead of killing the application, a system manager would be able to pause the application until everyone gets back from lunch. All of these functions should be administered from a nice management console that won't require too much training. Charged with updating the system, the IT shop understands that an easy-to-adapt nonintrusive application management framework is needed to make their custom, standalone Java application manageable. The team decides that the JMX framework would be a perfect fit. What Is JMX?The specification for Java Management Extensions (JMX) addresses the need for a common framework for managing applications. It provides Java developers a much-needed management architecture, a set of APIs, and several management services that can easily be added to enhance any Java application. Currently JMX is used heavily in the J2EE application server world. As more and more software products become J2EE enabled, JMX is becoming the de facto standard framework for Java-based application management. It's not only J2EE services that can take advantage of JMX but also standalone Java applications that can also benefit. Developing these features may take place either during the initial build of the application, or, as the example presents, as an afterthought.First let's get an understanding of the JMX architecture. The JMX architecture is three tier and easily integrated into any existing Java application. Figure 1 is adapted from the Sun Specification of JMX. It shows the three tiers and their components. It also shows where your preexisting application resides with respect to the rest of the management framework. The Instrumentation LayerIn the Instrumentation Layer, the Java developer exposes critical interfaces, objects, and components to the management interface by creating managed beans. JMX uses reflection to understand that an object is manageable, as such a managed bean (or MBean) is a class or interface whose name ends in the text "MBean", or a class that has in its hierarchy a class name ending in MBean (see www.sys-con.com/java/sourcec.cfm for more details). For example, a class Service would be considered an MBean if it was either renamed ServiceMBean or implemented an interface ServiceMBean.The standard MBean allows each object's members to be exposed based on a certain set of rules.
The Agent Layer The Distributed Services Layer What to Do?Now that we know what JMX is and how it can help us, let's walk through the steps involved in making your existing standalone Java application manageable through a simple HTTP service.Step 1: Figure out what needs to be managed. Step 2: Find the application code that will help expose management functions. Step 3: Write proxy MBeans that expose these functions. Step 4: Write the code that will register MBeans with the MBean Server. Step 5: Provide the MBean Server to a distributed adapter. Step 6: Manage your application. ConclusionUsing JMX as described can allow developers to quickly extend application components to deliver a simple yet functional management console. The example shown here shows the power of simply adding MBeans and JMX to your standalone application. The HTML adapter that is provided with the JMX Reference Implementation is enough to get a standalone Java application manageable in a short period of time. The JMX world becomes even more powerful when other adapters and distributed services are used. By using these and other features of JMX, more complex and robust solutions are easily contrived.ResourcesLATEST JAVA STORIES & POSTS
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK SPONSORED BY INFRAGISTICS
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||