【问题标题】:Timeout Expression in Spring Integration GatewaySpring 集成网关中的超时表达式
【发布时间】:2016-05-16 14:55:52
【问题描述】:

Spring Integration 的 Gateway 元素具有“default-reply-timeout”属性,但无法根据消息本身的数据设置超时值。我可以为每个可能的超时值创建一个网关,然后在运行时为该消息选择一个合适的网关,但这显然是一个讨厌的解决方法。

4.2 版向 TCPOutboundGateway 添加了“remote-timeout-expression”属性,但该更改并未影响到 GatewayProxyFactoryBean。

话虽如此,有没有办法在特定于消息的基础上配置超时?如果没有,“remote-timeout-expression”属性是否计划在某个时候移植到 GatewayProxyFactoryBean?

感谢您的帮助!

【问题讨论】:

    标签: java spring timeout spring-integration


    【解决方案1】:

    它目前是一个固定值,不能在逐个消息的基础上进行配置。

    我们当然可以考虑这样做,但它可能不会进入 4.3,因为the release candidate is already out

    一种可能的解决方法是使用MessagingTemplates 而不是网关。您可以设置MessagingTemplates 的集合,每个都配置了不同的超时,而不是网关:

     Foo result = this.templateWith10SecondTimeout.convertSendAndReceive(bar, Foo.class);
    

    或者,您可以向网关添加不同的方法,每种方法都有不同的回复超时时间。

    public interface GW {
    
         Foo waitTenSeconds(Bar bar);
    
         Foo waitTwentySeconds(Bar, bar);
    
    }
    

    默认超时是默认的,可以在每个方法上设置超时时间。

    【讨论】:

    • 感谢您的快速响应,这些变通办法目前似乎是一个不错的解决方案。至于在 GatewayProxyFactoryBean 中包含远程超时表达式,我可以为此提出功能请求吗?
    • 如果你想跟踪它,我已经打开了JIRA Issue
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-21
    • 2016-09-10
    • 1970-01-01
    • 1970-01-01
    • 2012-05-21
    • 2018-06-15
    相关资源
    最近更新 更多