GH-3844: Rework messaging annotation with @Bean (#3877)

* GH-3844: Rework messaging annotation with @Bean

Fixes https://github.com/spring-projects/spring-integration/issues/3844

* Make `MessagingAnnotationPostProcessor` as a `BeanDefinitionRegistryPostProcessor`
to process bean definitions as early as possible and register respective messaging
components at that early phase
* Make bean definitions parsing logic optional for AOT and native mode since beans
have bean parsed during AOT building phase
* Introduce a `BeanDefinitionPropertiesMapper` for easier mapping
of the annotation attributes to the target `BeanDefinition`
* Remove `@Bean`-related logic from method parsing process
* Change the logic for `@Bean`-based endpoint bean names:
since we don't deal with methods on the bean definition phase, then method name
does not make sense.
It even may mislead if we `@Bean` name is based on a method by default, so we end up
with duplicated word in the target endpoint bean name.
Now we don't
* Fix `configuration.adoc` respectively for a new endpoint bean name logic
* In the end the new logic in the `AbstractMethodAnnotationPostProcessor`
is similar to XML parsers: we feed annotation attributes to the
`AbstractStandardMessageHandlerFactoryBean` impls

* * Fix language in docs and exception message
This commit is contained in:
Artem Bilan
2022-08-22 12:38:23 -04:00
committed by GitHub
parent c1dbb02c51
commit ca138c0c06
33 changed files with 1136 additions and 819 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -19,10 +19,11 @@ package org.springframework.integration.bus;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
@@ -45,20 +46,20 @@ import org.springframework.messaging.support.GenericMessage;
*/
public class DirectChannelSubscriptionTests {
private TestApplicationContext context = TestUtils.createTestApplicationContext();
private final TestApplicationContext context = TestUtils.createTestApplicationContext();
private DirectChannel sourceChannel = new DirectChannel();
private final DirectChannel sourceChannel = new DirectChannel();
private PollableChannel targetChannel = new QueueChannel();
private final PollableChannel targetChannel = new QueueChannel();
@Before
@BeforeEach
public void setupChannels() {
this.context.registerChannel("sourceChannel", this.sourceChannel);
this.context.registerChannel("targetChannel", this.targetChannel);
}
@After
@AfterEach
public void tearDown() {
this.context.close();
}
@@ -80,8 +81,8 @@ public class DirectChannelSubscriptionTests {
@Test
public void sendAndReceiveForAnnotatedEndpoint() {
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(this.context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.postProcessBeanDefinitionRegistry((BeanDefinitionRegistry) this.context.getBeanFactory());
postProcessor.postProcessBeanFactory(this.context.getBeanFactory());
postProcessor.afterSingletonsInstantiated();
TestEndpoint endpoint = new TestEndpoint();
postProcessor.postProcessAfterInitialization(endpoint, "testEndpoint");
@@ -91,7 +92,7 @@ public class DirectChannelSubscriptionTests {
assertThat(response.getPayload()).isEqualTo("foo-from-annotated-endpoint");
}
@Test(expected = MessagingException.class)
@Test
public void exceptionThrownFromRegisteredEndpoint() {
AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
@@ -104,7 +105,8 @@ public class DirectChannelSubscriptionTests {
EventDrivenConsumer endpoint = new EventDrivenConsumer(sourceChannel, handler);
this.context.registerEndpoint("testEndpoint", endpoint);
this.context.refresh();
this.sourceChannel.send(new GenericMessage<>("foo"));
assertThatExceptionOfType(MessagingException.class)
.isThrownBy(() -> this.sourceChannel.send(new GenericMessage<>("foo")));
}
@Test
@@ -112,8 +114,7 @@ public class DirectChannelSubscriptionTests {
QueueChannel errorChannel = new QueueChannel();
this.context.registerChannel(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, errorChannel);
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(this.context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.postProcessBeanFactory(this.context.getBeanFactory());
postProcessor.afterSingletonsInstantiated();
FailingTestEndpoint endpoint = new FailingTestEndpoint();
postProcessor.postProcessAfterInitialization(endpoint, "testEndpoint");

View File

@@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.log.LogAccessor;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.context.IntegrationContextUtils;
@@ -105,7 +106,7 @@ public class CustomMessagingAnnotationTests {
MessagingAnnotationPostProcessor messagingAnnotationPostProcessor = new MessagingAnnotationPostProcessor();
messagingAnnotationPostProcessor.
addMessagingAnnotationPostProcessor(Logging.class, new LogAnnotationPostProcessor(beanFactory));
addMessagingAnnotationPostProcessor(Logging.class, new LogAnnotationPostProcessor());
return messagingAnnotationPostProcessor;
}
@@ -124,29 +125,24 @@ public class CustomMessagingAnnotationTests {
String value();
LoggingHandler.Level level() default LoggingHandler.Level.INFO;
}
private static class LogAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor<Logging> {
LogAnnotationPostProcessor(ConfigurableListableBeanFactory beanFactory) {
super(beanFactory);
}
@Override
protected String getInputChannelAttribute() {
return "value";
public String getInputChannelAttribute() {
return AnnotationUtils.VALUE;
}
@Override
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) {
LoggingHandler.Level level = MessagingAnnotationUtils.resolveAttribute(annotations, "level",
LoggingHandler.Level.class);
LoggingHandler loggingHandler = new LoggingHandler(level.name());
LoggingHandler loggingHandler = new LoggingHandler(level);
MethodInvokingMessageProcessor<String> processor = new MethodInvokingMessageProcessor<>(bean, method);
processor.setBeanFactory(this.beanFactory);
processor.setBeanFactory(getBeanFactory());
loggingHandler.setLogExpression(new FunctionExpression<>(processor::processMessage));
return loggingHandler;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -22,10 +22,11 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.integration.annotation.Filter;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.channel.DirectChannel;
@@ -54,16 +55,16 @@ public class FilterAnnotationPostProcessorTests {
private final QueueChannel outputChannel = new QueueChannel();
@Before
@BeforeEach
public void init() {
this.context.registerChannel("input", this.inputChannel);
this.context.registerChannel("output", this.outputChannel);
this.postProcessor.setBeanFactory(this.context.getBeanFactory());
this.postProcessor.afterPropertiesSet();
this.postProcessor.postProcessBeanDefinitionRegistry((BeanDefinitionRegistry) this.context.getBeanFactory());
this.postProcessor.postProcessBeanFactory(this.context.getBeanFactory());
this.postProcessor.afterSingletonsInstantiated();
}
@After
@AfterEach
public void tearDown() {
this.context.close();
}
@@ -111,7 +112,7 @@ public class FilterAnnotationPostProcessorTests {
@Test
public void filterAnnotationWithAdviceArray() {
TestAdvice advice = new TestAdvice();
context.registerBean("adviceChain", new TestAdvice[] { advice });
context.registerBean("adviceChain", new TestAdvice[]{ advice });
testValidFilter(new TestFilterWithAdviceDiscardWithin());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("testFilter.filter.filter");
assertThat(TestUtils.getPropertyValue(endpoint, "handler.adviceChain", List.class).get(0)).isSameAs(advice);
@@ -122,10 +123,10 @@ public class FilterAnnotationPostProcessorTests {
public void filterAnnotationWithAdviceArrayTwice() {
TestAdvice advice1 = new TestAdvice();
TestAdvice advice2 = new TestAdvice();
context.registerBean("adviceChain1", new TestAdvice[] { advice1, advice2 });
context.registerBean("adviceChain1", new TestAdvice[]{ advice1, advice2 });
TestAdvice advice3 = new TestAdvice();
TestAdvice advice4 = new TestAdvice();
context.registerBean("adviceChain2", new TestAdvice[] { advice3, advice4 });
context.registerBean("adviceChain2", new TestAdvice[]{ advice3, advice4 });
testValidFilter(new TestFilterWithAdviceDiscardWithinTwice());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("testFilter.filter.filter");
List<?> adviceList = TestUtils.getPropertyValue(endpoint, "handler.adviceChain", List.class);
@@ -151,10 +152,10 @@ public class FilterAnnotationPostProcessorTests {
public void filterAnnotationWithAdviceCollectionTwice() {
TestAdvice advice1 = new TestAdvice();
TestAdvice advice2 = new TestAdvice();
context.registerBean("adviceChain1", new TestAdvice[] { advice1, advice2 });
context.registerBean("adviceChain1", new TestAdvice[]{ advice1, advice2 });
TestAdvice advice3 = new TestAdvice();
TestAdvice advice4 = new TestAdvice();
context.registerBean("adviceChain2", new TestAdvice[] { advice3, advice4 });
context.registerBean("adviceChain2", new TestAdvice[]{ advice3, advice4 });
testValidFilter(new TestFilterWithAdviceDiscardWithinTwice());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("testFilter.filter.filter");
List<?> adviceList = TestUtils.getPropertyValue(endpoint, "handler.adviceChain", List.class);

View File

@@ -17,7 +17,6 @@
package org.springframework.integration.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -27,9 +26,10 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -149,14 +149,6 @@ public class MessagingAnnotationPostProcessorTests {
context.close();
}
@Test
public void testPostProcessorWithoutBeanFactory() {
MessagingAnnotationPostProcessor postProcessor =
new MessagingAnnotationPostProcessor();
assertThatIllegalArgumentException()
.isThrownBy(postProcessor::afterPropertiesSet);
}
@Test
public void testChannelResolution() {
TestApplicationContext context = TestUtils.createTestApplicationContext();
@@ -307,12 +299,12 @@ public class MessagingAnnotationPostProcessorTests {
context.close();
}
private MessagingAnnotationPostProcessor prepareMessagingAnnotationPostProcessor(
private static MessagingAnnotationPostProcessor prepareMessagingAnnotationPostProcessor(
ConfigurableApplicationContext context) {
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.postProcessBeanDefinitionRegistry((BeanDefinitionRegistry) context.getBeanFactory());
postProcessor.postProcessBeanFactory(context.getBeanFactory());
postProcessor.afterSingletonsInstantiated();
return postProcessor;
}

View File

@@ -166,8 +166,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
assertThat(receive.getPayload()).isInstanceOf(MessageRejectedException.class);
MessageRejectedException exception = (MessageRejectedException) receive.getPayload();
assertThat(exception.getMessage())
.contains("message has been rejected in filter: bean " +
"'messagingAnnotationsWithBeanAnnotationTests.ContextConfiguration.filter.filter.handler'");
.contains("message has been rejected in filter: bean 'filter.filter.handler'");
}
@@ -330,7 +329,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
@Bean
@ServiceActivator(inputChannel = "aggregatorChannel")
public MessageHandler aggregator() {
public AggregatingMessageHandler aggregator() {
AggregatingMessageHandler handler = new AggregatingMessageHandler(MessageGroup::getMessages);
handler.setCorrelationStrategy(new ExpressionEvaluatingCorrelationStrategy("1"));
handler.setReleaseStrategy(new ExpressionEvaluatingReleaseStrategy("size() == 10"));
@@ -355,7 +354,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
@Bean
@Splitter(inputChannel = "splitterChannel", reactive = @Reactive("reactiveCustomizer"))
public MessageHandler splitter() {
public DefaultMessageSplitter splitter() {
DefaultMessageSplitter defaultMessageSplitter = new DefaultMessageSplitter();
defaultMessageSplitter.setOutputChannelName("serviceChannel");
return defaultMessageSplitter;
@@ -470,7 +469,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
@Bean
@Splitter(inputChannel = "splitterChannel", applySequence = "false")
public MessageHandler splitter() {
public DefaultMessageSplitter splitter() {
return new DefaultMessageSplitter();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -21,10 +21,11 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.Collections;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Router;
import org.springframework.integration.channel.DirectChannel;
@@ -42,6 +43,8 @@ public class RouterAnnotationPostProcessorTests {
private final TestApplicationContext context = TestUtils.createTestApplicationContext();
private final MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
private final DirectChannel inputChannel = new DirectChannel();
private final QueueChannel outputChannel = new QueueChannel();
@@ -53,26 +56,26 @@ public class RouterAnnotationPostProcessorTests {
private final QueueChannel stringChannel = new QueueChannel();
@Before
@BeforeEach
public void init() {
context.registerChannel("input", inputChannel);
context.registerChannel("output", outputChannel);
context.registerChannel("routingChannel", routingChannel);
context.registerChannel("integerChannel", integerChannel);
context.registerChannel("stringChannel", stringChannel);
this.postProcessor.postProcessBeanDefinitionRegistry((BeanDefinitionRegistry) this.context.getBeanFactory());
this.postProcessor.postProcessBeanFactory(this.context.getBeanFactory());
this.postProcessor.afterSingletonsInstantiated();
}
@After
@AfterEach
public void tearDown() {
this.context.close();
}
@Test
public void testRouter() {
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.afterSingletonsInstantiated();
TestRouter testRouter = new TestRouter();
postProcessor.postProcessAfterInitialization(testRouter, "test");
context.refresh();
@@ -84,10 +87,6 @@ public class RouterAnnotationPostProcessorTests {
@Test
public void testRouterWithListParam() {
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.afterSingletonsInstantiated();
TestRouter testRouter = new TestRouter();
postProcessor.postProcessAfterInitialization(testRouter, "test");
context.refresh();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -18,10 +18,11 @@ package org.springframework.integration.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.Lifecycle;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.annotation.Splitter;
@@ -39,20 +40,20 @@ import org.springframework.messaging.support.GenericMessage;
*/
public class SplitterAnnotationPostProcessorTests {
private TestApplicationContext context = TestUtils.createTestApplicationContext();
private final TestApplicationContext context = TestUtils.createTestApplicationContext();
private DirectChannel inputChannel = new DirectChannel();
private final DirectChannel inputChannel = new DirectChannel();
private QueueChannel outputChannel = new QueueChannel();
private final QueueChannel outputChannel = new QueueChannel();
@Before
@BeforeEach
public void init() {
context.registerChannel("input", inputChannel);
context.registerChannel("output", outputChannel);
this.context.registerChannel("input", this.inputChannel);
this.context.registerChannel("output", this.outputChannel);
}
@After
@AfterEach
public void tearDown() {
this.context.close();
}
@@ -60,8 +61,8 @@ public class SplitterAnnotationPostProcessorTests {
@Test
public void testSplitterAnnotation() {
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
postProcessor.setBeanFactory(context.getBeanFactory());
postProcessor.afterPropertiesSet();
postProcessor.postProcessBeanDefinitionRegistry((BeanDefinitionRegistry) this.context.getBeanFactory());
postProcessor.postProcessBeanFactory(this.context.getBeanFactory());
postProcessor.afterSingletonsInstantiated();
TestSplitter splitter = new TestSplitter();
postProcessor.postProcessAfterInitialization(splitter, "testSplitter");

View File

@@ -298,11 +298,11 @@ public class EnableIntegrationTests {
private CountDownLatch inputReceiveLatch;
@Autowired
@Qualifier("enableIntegrationTests.ContextConfiguration2.sendAsyncHandler.serviceActivator")
@Qualifier("sendAsyncHandler.serviceActivator")
private AbstractEndpoint sendAsyncHandler;
@Autowired
@Qualifier("enableIntegrationTests.ChildConfiguration.autoCreatedChannelMessageSource.inboundChannelAdapter")
@Qualifier("autoCreatedChannelMessageSource.inboundChannelAdapter")
private Lifecycle autoCreatedChannelMessageSourceAdapter;
@Autowired
@@ -669,8 +669,7 @@ public class EnableIntegrationTests {
.isThrownBy(() -> this.metaBridgeInput.send(testMessage))
.withMessageContaining("Dispatcher has no subscribers");
this.context.getBean("enableIntegrationTests.ContextConfiguration.metaBridgeOutput.bridgeFrom",
Lifecycle.class).start();
this.context.getBean("metaBridgeOutput.bridgeFrom", Lifecycle.class).start();
this.metaBridgeInput.send(testMessage);
receive = this.metaBridgeOutput.receive(10_000);
@@ -697,8 +696,7 @@ public class EnableIntegrationTests {
.isThrownBy(() -> this.myBridgeToInput.send(testMessage))
.withMessageContaining("Dispatcher has no subscribers");
this.context.getBean("enableIntegrationTests.ContextConfiguration.myBridgeToInput.bridgeTo",
Lifecycle.class).start();
this.context.getBean("myBridgeToInput.bridgeTo", Lifecycle.class).start();
this.myBridgeToInput.send(bridgeMessage);
receive = replyChannel.receive(10_000);
@@ -741,8 +739,7 @@ public class EnableIntegrationTests {
assertThat(this.roleController.noEndpointsRunning("bar")).isFalse();
Map<String, Boolean> state = this.roleController.getEndpointsRunningStatus("foo");
assertThat(state.get("annotationTestService.handle.serviceActivator")).isEqualTo(Boolean.FALSE);
assertThat(state.get("enableIntegrationTests.ContextConfiguration2.sendAsyncHandler.serviceActivator"))
.isEqualTo(Boolean.TRUE);
assertThat(state.get("sendAsyncHandler.serviceActivator")).isEqualTo(Boolean.TRUE);
this.roleController.startLifecyclesInRole("foo");
assertThat(this.roleController.allEndpointsRunning("foo")).isTrue();
this.roleController.stopLifecyclesInRole("foo");
@@ -1690,6 +1687,7 @@ public class EnableIntegrationTests {
@InboundChannelAdapter(value = "counterChannel", autoStartup = "false", phase = "23")
public @interface MyInboundChannelAdapter {
@AliasFor(annotation = InboundChannelAdapter.class, attribute = "value")
String value() default "";
String autoStartup() default "";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2022 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.
@@ -67,7 +67,7 @@ public class BeanNameTests {
@SuppressWarnings("unused")
@Autowired
@Qualifier("eipBean.handler")
@Qualifier("eipBeanHandler")
private MessageHandler eipBeanHandler;
@SuppressWarnings("unused")
@@ -76,11 +76,11 @@ public class BeanNameTests {
@SuppressWarnings("unused")
@Autowired
@Qualifier("eipBean2.handler")
@Qualifier("eipBean2Handler")
private MessageHandler eipBean2Handler;
@Autowired
@Qualifier("eipBean2.handler.wrapper")
@Qualifier("eipBean2.handler")
private ReplyProducingMessageHandlerWrapper eipBean2HandlerWrapper;
@SuppressWarnings("unused")
@@ -98,7 +98,7 @@ public class BeanNameTests {
@SuppressWarnings("unused")
@Autowired
@Qualifier("eipSource.source")
@Qualifier("eipSourceSource")
private MessageSource<?> eipSourceSource;
@Test
@@ -124,10 +124,10 @@ public class BeanNameTests {
}
}
@Bean("eipBean.handler")
@Bean("eipBeanHandler")
@EndpointId("eipBean")
@ServiceActivator(inputChannel = "channel2")
public MessageHandler replyingHandler() {
public AbstractReplyProducingMessageHandler replyingHandler() {
return new AbstractReplyProducingMessageHandler() {
@Override
@@ -138,7 +138,7 @@ public class BeanNameTests {
};
}
@Bean("eipBean2.handler")
@Bean("eipBean2Handler")
@EndpointId("eipBean2")
@ServiceActivator(inputChannel = "channel3")
public MessageHandler handler() {
@@ -151,7 +151,7 @@ public class BeanNameTests {
return null;
}
@Bean("eipSource.source")
@Bean("eipSourceSource")
@EndpointId("eipSource")
@InboundChannelAdapter(channel = "channel3", poller = @Poller(fixedDelay = "5000"))
public MessageSource<?> source() {

View File

@@ -139,7 +139,7 @@ public class IntegrationGraphServerTests {
assertThat(links.size()).isEqualTo(34);
jsonArray =
JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'expressionRouter')]");
JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'expressionRouter.router')]");
Map<String, Object> expressionRouter = (Map<String, Object>) jsonArray.get(0);
assertThat(((List<?>) expressionRouter.get("routes")).size()).isEqualTo(0);
@@ -151,7 +151,7 @@ public class IntegrationGraphServerTests {
this.testSource.receive();
this.expressionRouterInput.send(MessageBuilder.withPayload("foo").setHeader("foo", "fizChannel").build());
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]");
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router.router')]");
String routerJson = jsonArray.toJSONString();
this.server.rebuild();
@@ -172,7 +172,7 @@ public class IntegrationGraphServerTests {
assertThat(links).isNotNull();
assertThat(links.size()).isEqualTo(37);
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]");
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router.router')]");
routerJson = jsonArray.toJSONString();
assertThat(routerJson).contains("\"sendTimers\":{\"successes\":{\"count\":4");
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'toRouter')]");
@@ -200,7 +200,7 @@ public class IntegrationGraphServerTests {
assertThat(sourceJson).contains("\"receiveCounters\":{\"successes\":2,\"failures\":1");
jsonArray =
JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'expressionRouter')]");
JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'expressionRouter.router')]");
expressionRouter = (Map<String, Object>) jsonArray.get(0);
JSONArray routes = (JSONArray) expressionRouter.get("routes");

View File

@@ -48,7 +48,6 @@ import org.springframework.integration.gateway.MessagingGatewaySupport;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.GenericMessage;
@@ -71,7 +70,7 @@ import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
*/
@SpringJUnitConfig
@DirtiesContext
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class)
@TestExecutionListeners(DependencyInjectionTestExecutionListener.class) // To ignore other default listeners
public class MicrometerMetricsTests {
@Autowired
@@ -149,7 +148,7 @@ public class MicrometerMetricsTests {
.counter().count()).isEqualTo(1);
assertThat(registry.get("spring.integration.send")
.tag("name", "eipBean.handler")
.tag("name", "eipBean")
.tag("result", "success")
.timer().count()).isEqualTo(1);
@@ -277,7 +276,7 @@ public class MicrometerMetricsTests {
SimpleMeterRegistry registry = new SimpleMeterRegistry();
registry.config().meterFilter(MeterFilter.deny(id ->
"channel".equals(id.getTag("type")) &&
"noMeters".equals(id.getTag("name"))));
"noMeters".equals(id.getTag("name"))));
return registry;
}
@@ -292,7 +291,7 @@ public class MicrometerMetricsTests {
@Bean("eipBean.handler")
@EndpointId("eipBean")
@ServiceActivator(inputChannel = "channel2")
public MessageHandler replyingHandler() {
public AbstractReplyProducingMessageHandler replyingHandler() {
return new AbstractReplyProducingMessageHandler() {
@Override