INT-1675: force initialization of other MBeanExporter instances before the integration monitor components are created
This commit is contained in:
@@ -11,19 +11,16 @@
|
||||
http://www.springframework.org/schema/integration/jmx
|
||||
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
|
||||
|
||||
<jmx:mbean-export server="mbs" default-domain="test.RouterMBean" />
|
||||
|
||||
<context:mbean-export server="mbs" default-domain="test.RouterMBean" />
|
||||
|
||||
<context:mbean-server id="mbs" />
|
||||
|
||||
<int:channel id="testChannel" />
|
||||
<int:channel id="intChannel" />
|
||||
<int:channel id="stringChannel" />
|
||||
|
||||
<int:payload-type-router id="ptRouter" input-channel="testChannel">
|
||||
<int:mapping type="java.lang.String" channel="stringChannel" />
|
||||
<int:mapping type="java.lang.Integer" channel="intChannel" />
|
||||
</int:payload-type-router>
|
||||
<int:router id="ptRouter" input-channel="testChannel" expression="payload instanceof String ? 'stringChannel' : 'intChannel'"/>
|
||||
|
||||
<context:mbean-server id="mbs" />
|
||||
|
||||
<context:mbean-export server="mbs" default-domain="test.RouterMBean" />
|
||||
|
||||
<jmx:mbean-export server="mbs" default-domain="test.RouterMBean" />
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -15,32 +15,56 @@ package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(Parameterized.class)
|
||||
public class RouterMBeanTests {
|
||||
|
||||
@Autowired
|
||||
private MBeanServer server;
|
||||
|
||||
|
||||
private ClassPathXmlApplicationContext context;
|
||||
|
||||
public RouterMBeanTests(String configLocation) {
|
||||
context = new ClassPathXmlApplicationContext(configLocation, getClass());
|
||||
server = context.getBean(MBeanServer.class);
|
||||
}
|
||||
|
||||
@Parameters
|
||||
public static List<Object[]> getParameters() {
|
||||
return Arrays.asList(
|
||||
new Object[] { RouterMBeanTests.class.getSimpleName() + "-context.xml" },
|
||||
new Object[] { RouterMBeanTests.class.getSimpleName() + "None-context.xml" },
|
||||
new Object[] { RouterMBeanTests.class.getSimpleName() + "Switch-context.xml" });
|
||||
}
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
if (context != null) {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRouterMBeanExists() throws Exception {
|
||||
// System.err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
|
||||
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
|
||||
Set<ObjectName> names = server.queryNames(
|
||||
new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
|
||||
assertEquals(1, names.size());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jmx
|
||||
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
|
||||
|
||||
<int:channel id="testChannel" />
|
||||
<int:channel id="intChannel" />
|
||||
<int:channel id="stringChannel" />
|
||||
|
||||
<int:router id="ptRouter" input-channel="testChannel" expression="payload instanceof String ? 'stringChannel' : 'intChannel'"/>
|
||||
|
||||
<context:mbean-server id="mbs" />
|
||||
|
||||
<!-- Same as RouterMBeanTests-context.xml but no Core MBeanExporter -->
|
||||
<jmx:mbean-export server="mbs" default-domain="test.RouterMBean" />
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context" xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:jmx="http://www.springframework.org/schema/integration/jmx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd
|
||||
http://www.springframework.org/schema/integration/jmx
|
||||
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
|
||||
|
||||
<int:channel id="testChannel" />
|
||||
<int:channel id="intChannel" />
|
||||
<int:channel id="stringChannel" />
|
||||
|
||||
<int:router id="ptRouter" input-channel="testChannel" expression="payload instanceof String ? 'stringChannel' : 'intChannel'"/>
|
||||
|
||||
<!-- Same as RouterMBeanTests-context.xml but switched order of MBeanExporters -->
|
||||
<jmx:mbean-export server="mbs" default-domain="test.RouterMBean" />
|
||||
|
||||
<context:mbean-server id="mbs" />
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user