INT-3286: Add @EnableMessageHistory
JIRA: https://jira.springsource.org/browse/INT-3286 Introduce `@EnableMessageHistory` and `MessageHistoryRegistrar`. Refactoring for `MessageHistoryParser` to use `MessageHistoryRegistrar` to follow with DRY Add test for `@EnableMessageHistory` INT-3286: Polishing INT-3286: Enable several MHs with the same value Previously the Framework allowed only one `<message-history>` independent of their `tracked-components`. With introduction of `@EnableMessageHistory` and `MessageHistoryRegistrar` the `MessageHistoryConfigurer` is improved to allow several `<message-history>` or `@EnableMessageHistory` with the same set of `componentNamePatterns`. INT-3286 Polishing + JMX + Docs * Allows setComponentNamePatterns and/or setComponentNamePatternsSet to be used as long as the settings are consistent. * Handle the case where the `MHC` was configured as a bean (no managed set exists) * Add support for changing the component name patterns over JMX + test case * Docs INT-3286 More Polishing * Change bean name to `messageHistoryConfigurer` * Move constant to `ICU` * Export the MBean by the `IMBE`
This commit is contained in:
committed by
Gary Russell
parent
d8e4818c5e
commit
2fd27e3a6c
@@ -13,10 +13,12 @@
|
||||
http://www.springframework.org/schema/integration/jmx
|
||||
http://www.springframework.org/schema/integration/jmx/spring-integration-jmx.xsd">
|
||||
|
||||
<context:mbean-export/>
|
||||
<context:mbean-export default-domain="#{T(java.util.UUID).randomUUID().toString()}"/>
|
||||
<context:mbean-server/>
|
||||
<jmx:mbean-export default-domain="#{T(java.util.UUID).randomUUID().toString()}"/>
|
||||
|
||||
<si:message-history/>
|
||||
|
||||
<si:channel id="channel"/>
|
||||
|
||||
<jmx:notification-publishing-channel-adapter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,14 +16,22 @@
|
||||
|
||||
package org.springframework.integration.jmx.config;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.Attribute;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.Notification;
|
||||
import javax.management.ObjectInstance;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -32,12 +40,13 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.jmx.JmxHeaders;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -132,6 +141,34 @@ public class NotificationPublishingChannelAdapterParserTests {
|
||||
assertEquals(1, names.size());
|
||||
}
|
||||
|
||||
@Test @DirtiesContext
|
||||
public void changeMessageHistoryPatterns() throws Exception {
|
||||
Set<ObjectInstance> mbeans = server.queryMBeans(null, null);
|
||||
boolean tested = false;
|
||||
for (ObjectInstance mbean : mbeans) {
|
||||
if (mbean.toString().contains("MessageHistoryConfigurer")) {
|
||||
ObjectName objectName = mbean.getObjectName();
|
||||
try{
|
||||
server.setAttribute(objectName, new Attribute("ComponentNamePatternsString", "foo, bar"));
|
||||
fail("Exception expected");
|
||||
}
|
||||
catch (MBeanException e) {
|
||||
assertThat(e.getTargetException(), instanceOf(IllegalStateException.class));
|
||||
assertThat(e.getTargetException().getMessage(), containsString("cannot be changed"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
server.invoke(objectName, "stop", new Object[]{}, new String[]{});
|
||||
server.setAttribute(objectName, new Attribute("ComponentNamePatternsString", "foo, bar"));
|
||||
assertEquals("bar,foo", server.getAttribute(objectName, "ComponentNamePatternsString"));
|
||||
tested = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(tested);
|
||||
}
|
||||
|
||||
private static class TestData {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user