Spring Integration 的 Gateway 元素具有“default-reply-timeout”属性,但无法根据消息本身的数据设置超时值。我可以为每个可能的超时值创建一个网关,然后在运行时为该消息选择适当的网关,但这显然是一个令人讨厌的解决方法。
版本 4.2 向 TCPOutboundGateway 添加了“远程超时表达式”属性,但该更改并未应用到 GatewayProxyFactoryBean。
话虽这么说,有没有办法根据特定消息配置超时?如果不是,“remote-timeout-expression”属性是否计划在某个时候移植到 GatewayProxyFactoryBean?
感谢您的帮助!
最佳答案
目前它是一个固定值,无法逐条消息进行配置。
我们当然可以考虑这样做,但它可能不会进入 4.3,因为 the release candidate is already out .
一种可能的解决方法是使用 MessagingTemplate
而不是网关。您可以设置一组 MessagingTemplate
,每个模板都配置不同的超时,而不是网关:
Foo result = this.templateWith10SecondTimeout.convertSendAndReceive(bar, Foo.class);
或者,您可以向网关添加不同的方法,每个方法都有不同的回复超时。
public interface GW {
Foo waitTenSeconds(Bar bar);
Foo waitTwentySeconds(Bar, bar);
}
默认超时是默认的,每个方法都可以设置超时。
关于java - Spring Integration Gateway 中的超时表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37256916/