-
1. Re: JMX and MBeanProxyExt.create
adrian.brock Jan 14, 2010 7:30 AM (in response to formenti)1 of 1 people found this helpfulI imagine what you are seeing is contention inside the JDK method MBeanServerFactory.findMBeanServer() which iterates
over a list in a synchonized block. That is what MBeanServerLocator.locate() uses.
Code from openjdk:
public synchronized static ArrayList<MBeanServer> findMBeanServer(String agentId) { checkPermission("findMBeanServer"); if (agentId == null) return new ArrayList<MBeanServer>(mBeanServerList); ArrayList<MBeanServer> result = new ArrayList<MBeanServer>(); for (MBeanServer mbs : mBeanServerList) { String name = mBeanServerName(mbs); if (agentId.equals(name)) result.add(mbs); } return result; }
To answer your other question. The generated proxy is threadsafe. So you can cache it and use it across many threads at once.
NOTE: MBeanProxyExt is largely redundant now. The JDK provides similar functionality since 1.5
http://java.sun.com/javase/6/docs/api/javax/management/MBeanServerInvocationHandler.html
-
2. Re: JMX and MBeanProxyExt.create
gifor Jan 14, 2010 12:50 PM (in response to adrian.brock)Thank you Adrian!
I tried to replace:
MBeanServer server = MBeanServerLocator.locate();
PhysicalSessionManagerMBean sessionManager = (PhysicalSessionManagerMBean) MBeanProxyExt.create(PhysicalSessionManagerMBean.class,"jboss.jmx:service=PhysicalSessionManager", server);
with:
MBeanServer server = MBeanServerLocator.locate();
ObjectName on = new ObjectName("jboss.jmx:service=PhysicalSessionManager");
PhysicalSessionManagerMBean sessionManager = (PhysicalSessionManagerMBean) MBeanServerInvocationHandler.newProxyInstance(server, on, PhysicalSessionManagerMBean.class,false);and now after 400.000 calls I get an average response time of these 3 lines of code of 0,3ms instead of 729ms... quite stange from my incompetent (I have limited knowledge of JMX) point of view.
Regards
Giovanni