View Full Version : using MBeanExporter with remote MBean server
mindstream
Aug 6th, 2006, 09:30 PM
How do I use the MBeanExporter to register my management beans with a remote MBean server? I want to be able to use either 1) another running instance of my spring container that exposes a ConnectorServerFactoryBean using a specific url, or 2) a 3rd party instance running either on the same physical server or on a remote server on my network.
I thought that setting locateExistingServerIfPossible to true on the MBeanServerFactoryBean would find a running mbean server on my local machine, but maybe it just finds a running mbean server running in the same VM?
I'm sure I'm just missing something. Can someone enlighten me?
Thanks.
mindstream
Aug 6th, 2006, 10:04 PM
just to clarify...
Basically, I want to register my MBeans with a central MBean server. I should have said that in the original post.
Does spring support this out of the box?
qvark
Aug 7th, 2006, 04:52 AM
I had a similar problem and I couldn't solve it with the support provided out-of-the-box. In my case, I wanted to register notification listeners against a remote MBeanServer (see my previous post http://forum.springframework.org/showthread.php?t=27473 for details).
I think it is basically a design flaw in the Spring JMX support, because the MBeanRegistrationSupport use a MBeanServer interface, which is intended only for local MBeanServers. IMHO, it should use the javax.management.MBeanServerConnection interface (which is a superinterface of MBeanServer) and then it would allow operations over a local or remote MBeanServer. I ended up making my own registration class, because the MBeanExporter didn't allow me to register notification listeners without register MBeans...
The configuration looks like:
<!-- Connector to the remote MBeanServer -->
<bean id="mbeanServerProxy1" class="org.springframework.jmx.support.MBeanServerConnect ionFactoryBean" lazy-init="false">
<property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:33333/IBJMXConnector"/>
</bean>
<!-- Bean that registers the JMX connector with the remote MBeanServer to listen notifications -->
<bean id="listenersRegisterer" class="es.indra.ibuilder.jmx.notifications.RemoteNotifica tionListenerRegisterer">
<property name="defaultServer">
<ref bean="mbeanServerProxy1"/>
</property>
<property name="notificationListeners">
<list>
<ref bean="jmxReadConnectorConfig"/>
</list>
</property>
</bean>
...
In your case you probably could rewrite the MBeanRegistrationSupport to use a MBeanServerConnection and then you should be able to use the MBeanExporter with remote MBeanServers. Something like:
<!-- Connector to the remote MBeanServer -->
<bean id="mbeanServerProxy1" class="org.springframework.jmx.support.MBeanServerConnect ionFactoryBean" lazy-init="false">
<property name="serviceUrl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:33333/IBJMXConnector"/>
</bean>
<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="server" ref="mbeanServerProxy1"/>
<property name="beans">
...
</bean>
Hope this helps,
Jose Luis.
Isaac2001
Feb 13th, 2008, 05:31 PM
On you example you register notification listener on a remote server, exists any form that you can inject beans obtained from a client connector to a local(POJO)bean?
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.