GH-3266: Don't override props in AnnGWProxyFB
Fixes https://github.com/spring-projects/spring-integration/issues/3266 It turns out that `AnnotationGatewayProxyFactoryBean.onInit()` implementation parses a `@MessagingGateway` attributes ignoring possible properties population by setters. This way a Java DSL `GatewayProxySpec` becomes useless since all its options are overridden by default values from a synthesized `@MessagingGateway`. Also it is inconsistency when we declare an `AnnotationGatewayProxyFactoryBean` as regular bean, but then called setters are ignored * Add `protected` getters into `GatewayProxyFactoryBean` for all the properties which can be overridden by annotation attributes * Fix `AnnotationGatewayProxyFactoryBean` to consult with those getters before populating a property with value from the annotation **Cherry-pick to 5.2.x**
This commit is contained in:
committed by
Gary Russell
parent
9ec6529992
commit
dc15910f2c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2020 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.
|
||||
@@ -37,6 +37,7 @@ import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.annotation.Gateway;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
@@ -44,6 +45,7 @@ import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.gateway.MethodArgsHolder;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
@@ -139,6 +141,13 @@ public class GatewayDslTests {
|
||||
assertThat(receive).isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.isEqualTo(defaultMethodPayload);
|
||||
|
||||
MessagingGatewaySupport methodGateway = gateways.values().iterator().next();
|
||||
MessagingTemplate messagingTemplate =
|
||||
TestUtils.getPropertyValue(methodGateway, "messagingTemplate", MessagingTemplate.class);
|
||||
|
||||
assertThat(messagingTemplate.getReceiveTimeout()).isEqualTo(10);
|
||||
assertThat(messagingTemplate.getSendTimeout()).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
@@ -194,7 +203,9 @@ public class GatewayDslTests {
|
||||
return IntegrationFlows.from(MessageFunction.class,
|
||||
(gateway) -> gateway
|
||||
.header("gatewayMethod", MethodArgsHolder::getMethod)
|
||||
.header("gatewayArgs", MethodArgsHolder::getArgs))
|
||||
.header("gatewayArgs", MethodArgsHolder::getArgs)
|
||||
.replyTimeout(10)
|
||||
.requestTimeout(20))
|
||||
.bridge()
|
||||
.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user