-
1. Re: 2.0 and JMX
brian.stansberry Apr 20, 2007 1:24 PM (in response to fredrikj)In JBC 2.0, the cache no longer self registers; you have to do it manually. Basically, we recognized that JMX integration is really not a core function of the cache, and 1) should be done by external code that understands the JMX environment, and 2) should be extracted into a separate class.
What you should do is:Cache cache = createCache(); MBeanServer mbs = getMBeanServer(); mbs.registerMBean(new org.jboss.cache.jmx.CacheJmxWrapper(cache), monitorName);
CacheJmxWrapper exposes a property "registerInterceptors", which defaults to true. When you register the wrapper in JMX, it gets a callback from JMX (via MBeanNotification interface) and if registerInterceptors=true it will register mbeans for all the interceptors.
I haven't looked at this for a while, and it may not work yet, but you can also try this semi-hacky trick:Cache cache = createCache(); MBeanServer mbs = getMBeanServer(); mbs.registerMBean(new org.jboss.cache.jmx.CacheLegacyJmxWrapper(cache), monitorName);
(note use of CacheLegacyJmxWrapper).
CacheLegacyJmxWrapper actually exposes via JMX getters for a lot of the configuration options.
I'll defer to Manik as to whether he wants to expose getMembers(). -
2. Re: 2.0 and JMX
nnnnn Jul 5, 2007 10:58 AM (in response to fredrikj)A couple of things:
It would be a good idea if this were documented. The 2.0 documentation still implies that no registration is necessary for JMX.
Second, anybody have quick hints (or links) for a JMX newbie? I'm not really interested in learning so much about it right now - I just want to be able to use jconsole to check the state of jbosscache 2.0 in a standalone app.... Particularly, in the code snippets in the thread, I don't know how to get the mbean server or what the monitor name should be (I've figured out that there's an MBeanServerFactory and I can create or get an mbean server from that, I'm not sure whether I should create one or get one, and how the names relate).
Thanks. -
3. Re: 2.0 and JMX
nnnnn Jul 5, 2007 11:51 AM (in response to fredrikj)To answer my own question, this seems to work:
_cache = createCache(); ArrayList mbServers = MBeanServerFactory.findMBeanServer( null ); if (mbServers.size() > 0) { MBeanServer mbs = (MBeanServer) mbServers.get( 0 ); mbs.registerMBean( new org.jboss.cache.jmx.CacheJmxWrapper( _cache ), new ObjectName( JmxUtil.getDefaultCacheObjectName( _cache ) ) ); }
-
4. Re: 2.0 and JMX
brian.stansberry Jul 5, 2007 12:01 PM (in response to fredrikj)Yes, what you are doing is correct.
You're right about the docs. This whole area of the docs was completely rewritten for 2.0.0.CR3, which should be out within a couple days. -
5. Re: 2.0 and JMX
fredrikj Jul 5, 2007 12:29 PM (in response to fredrikj)I omitted the getMbeanServer() since it is environment dependent. A oneliner approach to getting the default server is like this:
private MBeanServer getMBeanServer() { return ManagementFactory.getPlatformMBeanServer(); }