Developer

Does O'Reilly's new book explain what you need to know about JMX?

What is JMX and why would you want to use it? Find out whether this new book from O'Reilly might get you going in the right direction.


JMX is the new Java standard for managing application resources. It's designed to work with existing solutions, such as Simple Network Management Protocol (SNMP) and Web-Based Enterprise Management (WBEM), and to maintain standards among all the new J2EE management interfaces. JMX allows Java developers to create a way to maintain an application through some form of administrative interface, instead of through log files and the command line.

Prior to coming across O’Reilly’s Java Management Extensions, I had used JMX to build monitoring components for our JBoss application server. I had created Managed Beans (MBeans), the simplest kind of JMX bean, and plugged them into the server. Then, by accessing a Web page, I could see the list of MBean services in the system, and even start, stop, or modify them. This made it very easy for me to see how many users we currently had attached to our custom server, and even to restart any hung threads. But I wanted some understanding of what was going on underneath the framework I was using in our J2EE solution. That’s what I hoped to get from this title. But as you’ll see, I was a little disappointed. Figure A gives a quick overview of my impressions.
Figure A

Java Management Extensions

By J. Steven Perry
O'Reilly, 2002
312 pages

ISBN: 0-596-00245-9
Cover price: $34.95

Highs:
Introduction provides good, brief view of the world of JMX
Much easier read than the specifications themselves
Points out current bugs at time of publishing
Lows:
Isn’t much more than a detailed explanation of the JMX spec
Lack of examples of how to use JMX today
Some chapters are very similar, making them a hard read


I found Java Management Extensions to be disappointing.

The book is organized into two sections, one for each level of JMX functionality. The first section covers the instrument level, which includes various types of MBeans that you can extend to create a JMX-aware application. The second section discusses the agent level, which explains the environment in which MBeans will be placed and function. Technically there is a third level, the distributed services level, but this level is not a finished part of the specification yet. So, the author understandably limits himself to discussing distributed services only in the introduction.

The all-important introduction
It's fairly uncommon to view the introduction of a book as an important chapter, and yet with this book it is a critical part. The introduction provides you with a high-level overview of the JMX specification, which you’ll need to understand in order to follow the rest of the text. It even goes so far as to provide an example, albeit a very abstract one.

After the introduction, the book gets straight into the guts of JMX and introduces the MBean. There are four types of MBeans—Standard, Dynamic, Model, and Open—and thus four chapters on them, one devoted to each. Each chapter takes the form of a page explaining when and why that particular type of MBean should be used and includes a detailed description of how it works. These first four chapters take up the first 140 pages—nearly fifty percent of the book—and cover the instrumentation level of JMX.

While the book does take you carefully through each type of MBean, I found it to be a hard slog. Due to the similarity of each type of MBean, the first four chapters seem to never really get going, and I wound up having to push myself to make it through them. Each chapter includes an example, but they all basically boil down to applying MBeans to a boring queue. Perhaps focusing on something a bit livelier than a queue would have helped keep things interesting.

Understanding the MBean environment
The second half of the book represents the middle agent level of the three JMX layers. This section covers what makes up the container that MBeans fit into, the MBean server and notification model, and a list of standard services that each JMX container may be expected to have. While I found that these chapters gave me an awareness of the things I could be doing in my managed server, they didn't really provide me with ideas on how to use the MBeans or how the things I was learning might apply to my code.

An example of how to write a service would have been a very interesting addition here. At work, we replaced a Timer service with a service based on Quartz, an open source cron-like API in Java, and have been happily using it in production. An example of a service the author has written would have been nice here, or even at the end of the book.

Disappointing lack of examples
As I said, I came to this book looking for something to show me the structure underneath the framework I was happily using with my J2EE solution. While Java Management Extensions did this, it didn’t exactly light a fire in me to run off and apply any of the things I’d learned. There really isn’t anything glaringly wrong with the book; the author's style is not unpleasant, he shows comprehension of the JMX specification, and covers the subject matter well. Still, something about it just didn’t click for me.

I think the problem might be that the usefulness I get from JMX doesn't come across at all in this book. For me anyway, I think it fails to provide a good picture of why you’d want JMX in the first place because it lacks compelling examples. Think of a book on servlets that fails to provide alluring examples of servlets running in a container, and you’ll get the picture. Perhaps a lot of my problems can be ascribed to the newness of JMX, but that doesn't excuse the lack of interesting examples.

The final word
If you’re already using MBeans, you can’t really go wrong by adding this book to your arsenal. It will happily serve most of your reference needs, saving you from hunting around on the Web or in your J2EE container's documentation. If, like me, you feel you're only grazing the outer reaches of JMX in your day-to-day use, this book will show you what lies beyond.

However, if you aren’t currently using JMX, and looking for a book that will introduce you to JMX and allow you to comprehend it, I would wait for the second edition. Maybe by that time JMX will be more mature and the author will have examples of containers and MBeans to plug in, as well as a third-section written on distributed services. In short, don’t buy it; just go read the introduction in a bookstore.

Editor's Picks

Free Newsletters, In your Inbox