Is there anything similar to the Spring JMX exporter out there WITHOUT using the Spring framework?
SimpleJMX seems to be reasonable but seems also to be a very young framework pushed only by a single person.
I'm in need of exposing a whole bunch of attributes, methods and classes as JMX but don't want to fiddle with the JMX API and writing tons of JMX interfaces.
And there is no way to introduce Spring in the project (just in case you ask). Any hints or ideas are greatly appreciated :-)
Ok, I have quickly evaluated SimpleJMX and JMXUtils. Both work as expected and are very similar to the Spring JMX exporter. However, I find JMXUtils to be more usable in my case.
With JMXUtils it is very easy to register/unregister MBeans to an already started platform mbean server. In my case I was using GlassFish V3 as application server and I didn't want to start another MBean Server just for my own mbeans.
As far as I can see the API of SimpleJMX does not allow this and you are either forced to start another MBeanServer using the SimpleJMX API and register the created mbeans (very easy with the API) or you start fiddling around with trying to register the mbeans into the platform mbean server. The later is a little bit more complicated and therefore I decided to use JMXUtils.
The downside of JMXUtils is the manipulation of the bean name. SimpleJMX uses attributes in annotations (domainName, beanName) which is very useful but with JMXUtils you have to know the syntax for naming mbeans when using mbean domains. All in all not a big deal but for my taste SimpleJMX has the better solution for this.
The bottom line is, that both libraries are great and do their job. I decided to use JMXUtils.
I cam accross org.weakref.jmxutils
library in commons-dbcp-jmx. Check out ManagedBasicDataSource.java
for an example:
@Managed(description = "The current number of active connections that have been allocated from this data source.")
public synchronized int getNumActive() {
return super.getNumActive();
}
I've never used that library myself, but seems to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With