【发布时间】:2015-05-02 00:27:46
【问题描述】:
我有以下 spring-integration XML 配置
<ip:tcp-outbound-gateway id="outboundClient"
request-channel="requestChannel"
reply-channel="string2ObjectChannel"
connection-factory="clientConnectionFactory"
request-timeout="10000"
reply-timeout="10000"/>
如何编写与上述等效的 Java 配置? 我认为等价的将是
@Bean
public TcpOutboundGateway outboundClient() {
TcpOutboundGateway tcpOutboundGateway = new TcpOutboundGateway();
tcpOutboundGateway.setConnectionFactory(clientConnectionFactory());
tcpOutboundGateway.setRequiresReply(true);
tcpOutboundGateway.setReplyChannel(string2ObjectChannel());
tcpOutboundGateway.setRequestTimeout(10000);
tcpOutboundGateway.setSendTimeout(10000);
return tcpOutboundGateway;
}
但我找不到设置请求通道的方法。 任何帮助将不胜感激。
谢谢
【问题讨论】:
-
您还需要调用方法
afterPropertiesSet(),这不会通过ConvertionService使用任何已注册的转换器。我解决这类问题的方法是查看源代码,因为 Spring 在幕后做了很多魔法。 -
我确实看过源代码,但是没有办法设置请求通道。一开始我以为OutputChannel是请求通道,但是setReplyChannel实际上是在内部设置outputChannel。
标签: java spring spring-integration spring-java-config