Skip navigation
2005

Dimitris Andreadis's Blog

March 2005 Previous month Next month
dimitris

Platform MBeans in JDK5

Posted by dimitris Mar 29, 2005

 

JDK5 comes bundled with a JMX v1.2 implementation and a set of monitoring MBeans called platform MBeans or MXBeans (do not confuse those with JBoss XMBeans :) Those MXBeans can be accessed through the platform MBeanServer, which is more or less a normal MBeanServer but it is instantiated by the JVM itself, upon first access.

 

A nice example of underlying usage of a platform MBean can be seen in (soon-to-be-released) JBoss v3.2.8/4.0.2. By utilizing the ThreadMXBean we can output to the jmx-console a full stack trace of all running threads in JBoss, without having to revert to the command line (as it was done previously). Of course, this only works when running under a JDK5+ runtime.

 

Check out our wiki for more info.

 

dimitris@jboss

 

It comes without surprise that advanced developers routinely extend JBoss with their own MBean services to do all sorts of interesting stuff. Additionaly, it is often the case that the produced mbean code is of a generic nature, or the developer has come up with a not-so-common use-case for which mbeans are a good fit.

 

Unfortunately (and this is often the nature of OpenSource), we rarely hear back from them! Wouldn't be great if we could somehow share the knowledge, or even better, incorporate some of the best ideas back to the JBoss codebase?

 

Driven by a request from this fellow here, I created a simple entry point in the JBoss Wiki for anyone that wants to share his/her experience with MBeans, or even better, some working piece of generic MBean code.

 

You may also try the JBoss User -> Management, JMX/JBoss forum as a starting point for discussing your own unique mbean use-case.

 

See you at the forums!

 

dimitris@jboss

 

In case you don't already know, ListenerServiceMBeanSupport is a cool subclass that you can extend if you want to write MBean services that are jmx notification listeners, too.

 

It solves the problem of subscribing for notifications, by externalizing the subscription configuration in XML, no matter how complex it is. It has some nice features like you can use ObjectName patterns (e.g. subscribe to all mbeans in the jboss.system domain (jboss.system:*) and it supports dynamic subscriptions too, that is, the baseclass will monitor new mbean registration and it'll subscribe to them if they match the subscription specification you have provided, even AFTER your service is started . You just need to write the callback (handleNotification2()) to process the received notifications. (Have a look at an example here.)

 

Starting from JBoss v3.2.8RC1 & v.4.0.2RC1, this mechanism has been extended to support arbitrary filters, too, using a filter factory plugin mechanism. (Previously you were only able to specify a NotificationFilterSupport filter.)

 

To learn all about this, take a look at the SubscriptionList examples in the Wiki documentation.

 

If you have some rather peculiar JMX notification subscription scenario that you cannot implement using ListenerServiceMBeanSupport, I'd be very interested to hear about, so please do post a message at the Users, Management,JMX/JBoss forum.

 

Enjoy!

 

dimitris@jboss

 

Most of the presentation slides from JBossWorld can now be found online at JBoss World Recap. There is a lot of valuable information in many of those presentation, so I would highly recommend everyone to have a look at the presentations corresponding to their subjects of interest.

 

I did a presentation as well, focused around the 3.x/4.x JBoss MicroContainer, under the title "Never Write A main() Again!". The original intension was to show that in most cases in which a server application needs to be created, whether it is EJB based or not, it makes perfect sense to reuse the JBoss MicroContainer (for example, start off with the "minimal" configuration) and just add your own extension in the form of MBean Services, rather than starting from scratch.

 

The same is true for your normal J2EE application, where you just want to add functionality to the server that is difficult to write using the "standard" J2EE tools (for example, a lightweight adapter to an external system, without the burden of creating a JCA resource).

 

In any case, the benefit is a very high degree of reusability of components that are really well tested and difficult to write (e.g. the unified classloading mechanism of JBoss that makes hot-deployment possible).

 

I've been doing MBean services with JBoss for almost 4 years now and while the whole idea is very neat and simple, it is impressive how few people actually know about the existence of this technology and its many uses. Most developers only get to learn about this in one of the JBoss trainings.

 

We now see the proliferation of various container-like projects coming about as the new "cool" thing, while it is true that JBoss has been doing this kind of stuff since year 2001.

 

In any case, I tried to distill in just a few slides the really essential stuff that you need to know in order to write your own MBean. This is not rocket science at all, and I usually need 15-20 minutes to get someone up to speed with writing her own MBeans and start extending JBoss in arbitrary ways. In fact, it is often the case that people, after they write their first MBean and see how easy it is, they want to go about and MBean-ize everything :)

 

Anyway, I hope you find the presentations useful.

dimitris

Welcome (Back)

Posted by dimitris Mar 6, 2005

 

After being with JBoss for almost a year now, and in the aftermath of JBossWorld (which was awesome, btw) I thought I should make my first blogging attempt. I hope I won't get to increase the entropy of the universe with useless rants and I'm certainly against those know-it-all bloggers that seem to have an opinion about everything and everyone. So I'll try to stick to where I suspect I may have something useful to say. In any case, if this is all seems Greek to you, this will be certainly my own fault :)

 

JBossWorld was great for many reasons, I got to meet once more the usual suspects, old and new JBoss developers, and a great deal of new people and others that  I only "virtually" knew through the forums. This is particularly important if you are a "remote" employee, who lives and breaths through an ADSL connection, so every opportunity for real interactions is simply invaluable.

 

We also had our "internal" JBoss Developer's conference before and after the main event, where we got to discuss the various JBoss projects, subsystems, roadmaps, new developments, etc. On the flight back home my head was still spinning from the design sessions, and the tons of ideas that naturally pop up in such a great environment (late night alcohol sessions might have something to do with that, too.) In any case, there was so much brain power in that conference room, amazing and exhausting at the same time. I just feel like going back and relaxing for a couple of days. We have lots of work to do :)

Filter Blog

By date: