Controlling MBean Registration Behavior in Spring

In Spring 1.2.5 I modified the MBeanExporter to provide users with more control over MBean registration. Previously, the MBeanExporter would attempt to register an MBean and fail if that MBean already existed. In many cases this is the desired behavior; however there are two particular cases where this behavior is not desirable:

  1. You have many applications sharing an MBean - perhaps as a mechanism for sharing data
  2. You have a situation whereby an MBean may not be unregistered when redeploying the application

In the first situation, you are deloying multiple applications each of which wants to register and access the same MBean say, for example, spring:type=Shared. Previously in Spring, the first application you deployed would deploy successfully and all others would fail when trying to register the shared MBean. As of Spring 1.2.5, you can get around this by setting the registrationBehaviorName property of the MBeanExporter to REGISTRATION_IGNORE_EXISTING, instructing MBeanExporter to attempt to register the MBean and continue happily along if it finds that MBean is already registered. So in the scenario I highlighted, the first application would go ahead and register the MBean spring:type=Shared and each subsequent application would simply detect that this MBean already existed and continue through the registration process.

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
        ...
	<property name="registrationBehaviorName" value="REGISTRATION_IGNORE_EXISTING"/>
	...
</bean>

In the second scenario, you are deploying the same application again and again, perhaps in a development environment, but application server is not correctly signalling the application shutdown to Spring. As such, the MBeanExporter is unaware that it should be unregistering its MBeans and the MBeans are left registered when you come to redeploy the application. In this case, you can set the registrationBehavior property to REGISTRATION_REPLACE_EXISTING and have the MBeanExporter simply unregister the residual MBean and replace it with the new one.

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
        ...
	<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
	...
</bean>

This is just the first of many new JMX-related features coming to Spring in the coming months. In the 1.3 release we will have support for JMX notifications, enabling you to configure notification listeners using Spring and to access notification publication infrastructure. We are introducing a new MBeanInfoAssembler, which allows you to define MBean interfaces using an XML descriptor, plus we will be improving the MBeanExporter itself to allow you to register your own MBeans at runtime using Spring’s management interface generation capabilities. In the longer term we will be adding JMX management capabilities to Spring itself allowing you to control and monitor aspects of framework. In particular, we will be focusing on adding monitoring capabilties to the JDBC and MVC components of the framework.

 

WordPress database error: [Can't open file: 'robh_comments.MYI' (errno: 145)]
SELECT * FROM robh_comments WHERE comment_post_ID = '5' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply