Thursday, May 11, 2006

JMX names

Sun's advice
  • Allways have type=
  • if singleton ( or one instance per domain ) - no  other key
  • otherwise: add name=
  • for grouping, add group=
  • j2eeType/jsr77 - they kind of agree it's a messs -  I think
  • they do actually define a 'containment scheme', using type=Server.Application.WebModule,..  and  Server=, Application=, etc. Not quite JSR77 - but close enough., and it makes more sense.
  • of course - an easier solution would be to just use  unix-like names name=//servername/appname/webname,
On mbeans, they advise:
  • use standard MBeans - and use the interface with newProxyInstance. Not sure I agree with this one, if you want this kind of programmatic access use RMI/corba/etc if out of process, and the object directly if you are in process - you still have coupling and dependency, but no need for the JMX layer, which is not designed as RPC and is more inefficient than direct calls.
  • advice against DynamicMBeans - instead extend StandardMBean.  I strongly disagree with this one.
  • On model mbeans, the correctly mention that they are hard to use by themself. The fact that they can't have interfaces is false AFAIK, you can define the interfaces if you want and the proxy will be generated, you can construct a dynamic proxy for anything if you want to write the interface. There is a decoupling since the implementation doesn't have to implement the method, but this can happen in any case if one side changes attributes/methods. See the above point on why I think dynamic proxies for JMX are a convoluted and bad idea.
  • recommend using OpenMbeans - good idea, and avoiding RMI-specific features like downloading classes.
As usual for any 'best practice' document - don't believe all they say, ask first what 'practice' they had and how many applications they developed or considered before finding the 'best', and how they relate to your use case.