Revise MessageHistory configuration
Currently the `MessageHistoryRegistrar` can parse several sources for message history - `@EnableMessageHistory` and/or `<message-history>`. Since its logic relies on the reflection it is not compatible with Spring Native. Plus it causes confusion when several sources are declared so when time comes to change something in that configuration, we may miss some place to re-align with our new requirements. Better to reject extra configurations and enforce end-users to use only one `@EnableMessageHistory` or `<message-history>`. This is actually a preferences for many other `@Enable...` in Spring portfolio. Plus we got a benefit with a Spring Native compatibility * Fix `MessageHistoryRegistrar` to parse only one `@EnableMessageHistory`. Register `MessageHistoryConfigurer` function way for Spring Native compatibility * Clean up `PublisherRegistrar` for better readability * Fix message history tests which exposed several configurations * Add JavaDoc into `EnableMessageHistory` * Refactor `MessageHistoryConfigurer` to let to override patterns configuration at runtime * Clean up `message-history.adoc`
This commit is contained in:
committed by
Gary Russell
parent
0fba06b206
commit
b35dc9d754
@@ -12,8 +12,6 @@
|
||||
<!--INT-3853 -->
|
||||
<context:property-placeholder location="classpath:org/springframework/integration/configuration/EnableIntegrationTests.properties"/>
|
||||
|
||||
<message-history tracked-components="publishedChannel,input,annotationTestService*"/>
|
||||
|
||||
<channel-interceptor pattern="none">
|
||||
<wire-tap channel="bar" />
|
||||
</channel-interceptor>
|
||||
|
||||
@@ -800,7 +800,6 @@ public class EnableIntegrationTests {
|
||||
@EnableIntegration
|
||||
// INT-3853
|
||||
// @PropertySource("classpath:org/springframework/integration/configuration/EnableIntegrationTests.properties")
|
||||
@EnableMessageHistory({ "input", "publishedChannel", "annotationTestService*" })
|
||||
public static class ContextConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
@@ -57,9 +57,8 @@ public class MessageHistoryIntegrationTests {
|
||||
Map<String, ConsumerEndpointFactoryBean> cefBeans = ac.getBeansOfType(ConsumerEndpointFactoryBean.class);
|
||||
for (ConsumerEndpointFactoryBean cefBean : cefBeans.values()) {
|
||||
DirectFieldAccessor bridgeAccessor = new DirectFieldAccessor(cefBean);
|
||||
String handlerClassName = bridgeAccessor.getPropertyValue("handler").getClass().getName();
|
||||
assertThat("org.springframework.integration.config.MessageHistoryWritingMessageHandler"
|
||||
.equals(handlerClassName)).isFalse();
|
||||
Boolean shouldTrack = (Boolean) bridgeAccessor.getPropertyValue("handler.shouldTrack");
|
||||
assertThat(shouldTrack).isFalse();
|
||||
}
|
||||
ac.close();
|
||||
}
|
||||
@@ -226,7 +225,7 @@ public class MessageHistoryIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testMessageHistoryMoreThanOneNamespaceFail() {
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
assertThatExceptionOfType(BeanDefinitionStoreException.class)
|
||||
.isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespace-fail.xml",
|
||||
MessageHistoryIntegrationTests.class));
|
||||
|
||||
Reference in New Issue
Block a user