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:
@@ -139,14 +139,14 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Test
|
||||
public void testPollingFlow() {
|
||||
this.controlBus.send("@'jmsTests.ContextConfiguration.integerMessageSource.inboundChannelAdapter'.start()");
|
||||
this.controlBus.send("@'integerMessageSource.inboundChannelAdapter'.start()");
|
||||
assertThat(this.beanFactory.getBean("integerChannel")).isInstanceOf(FixedSubscriberChannel.class);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Message<?> message = this.outputChannel.receive(20000);
|
||||
assertThat(message).isNotNull();
|
||||
assertThat(message.getPayload()).isEqualTo("" + i);
|
||||
}
|
||||
this.controlBus.send("@'jmsTests.ContextConfiguration.integerMessageSource.inboundChannelAdapter'.stop()");
|
||||
this.controlBus.send("@'integerMessageSource.inboundChannelAdapter'.stop()");
|
||||
|
||||
assertThat(((InterceptableChannel) this.outputChannel).getInterceptors())
|
||||
.contains(this.testChannelInterceptor);
|
||||
@@ -353,7 +353,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
public IntegrationFlow jmsMessageDrivenFlow() {
|
||||
return IntegrationFlow
|
||||
.from(Jms.messageDrivenChannelAdapter(amqFactory,
|
||||
DefaultMessageListenerContainer.class)
|
||||
DefaultMessageListenerContainer.class)
|
||||
.outputChannel(jmsMessageDrivenInputChannel())
|
||||
.destination("jmsMessageDriven")
|
||||
.configureListenerContainer(c -> c.clientId("foo")))
|
||||
@@ -406,23 +406,23 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
@Bean
|
||||
public IntegrationFlow jmsInboundGatewayFlow() {
|
||||
return IntegrationFlow.from(
|
||||
Jms.inboundGateway(amqFactory)
|
||||
.requestChannel(jmsInboundGatewayInputChannel())
|
||||
.replyTimeout(1)
|
||||
.errorOnTimeout(true)
|
||||
.errorChannel(new FixedSubscriberChannel(new AbstractReplyProducingMessageHandler() {
|
||||
Jms.inboundGateway(amqFactory)
|
||||
.requestChannel(jmsInboundGatewayInputChannel())
|
||||
.replyTimeout(1)
|
||||
.errorOnTimeout(true)
|
||||
.errorChannel(new FixedSubscriberChannel(new AbstractReplyProducingMessageHandler() {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
return "error: " +
|
||||
((MessageTimeoutException) requestMessage.getPayload())
|
||||
.getFailedMessage().getPayload() + " is not convertible";
|
||||
}
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
return "error: " +
|
||||
((MessageTimeoutException) requestMessage.getPayload())
|
||||
.getFailedMessage().getPayload() + " is not convertible";
|
||||
}
|
||||
|
||||
}))
|
||||
.requestDestination("jmsPipelineTest")
|
||||
.configureListenerContainer(c ->
|
||||
c.transactionManager(mock(PlatformTransactionManager.class))))
|
||||
}))
|
||||
.requestDestination("jmsPipelineTest")
|
||||
.configureListenerContainer(c ->
|
||||
c.transactionManager(mock(PlatformTransactionManager.class))))
|
||||
.filter(payload -> !"junk".equals(payload))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.get();
|
||||
|
||||
Reference in New Issue
Block a user