【问题标题】:Enricher Pattern with multiple webservice calls使用多个 Web 服务调用来丰富模式
【发布时间】:2014-06-18 03:14:40
【问题描述】:

如何在使用丰富模式时使用过滤或从链中返回

这是我的场景 我正在使用丰富器模式从请求通道中检索数据,然后用于丰富有效负载。 请求通道将调用多个 Web 服务来检索数据。仅当第一个具有有效数据时才需要调用第二个 Web 服务。如果没有,我需要返回浓缩器。 当过滤器发生时,我得到这个异常 org.springframework.integration.handler.ReplyRequiredException: No reply generated by handler

我的消息流是否正确或需要添加其他内容?

    <si:enricher id="enricher" input-channel="channelone"
request-channel="retrieveDataChannel" output-channel="outputChannel" >
    <si:property name="amount"    expression="payload.amount"/>

</si:enricher>


<si:chain id="dataChain" input-channel="retrieveDataChannel"  >
    <si:header-enricher >
        <si:header name="Content-Type" value="application/json" />
    </si:header-enricher>   


    <si-http:outbound-gateway id="Gateway1" 
                       url="http://$webservice{host}"                                               
                       http-method="POST" 
                       rest-template="restTemplate"
                       expected-response-type="com.xxx.response.Response1">
    </si-http:outbound-gateway>     

    <si:filter expression="payload.amount lt 30"  />



    <si-http:outbound-gateway id="Gateway2" 
                       url="http://$webservice{host}"                                               
                       http-method="POST" 
                       rest-template="restTemplate"
                       expected-response-type="com.xxx.response.AmountResponse">
    </si-http:outbound-gateway>         


</si:chain> 

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    如果您处于请求/回复流中,则不能只在链中添加&lt;filter/&gt;;浓缩器将永远等待回复。

    最简单的方法是将第二个网关移出链,并将链的最后一个组件设为&lt;router/&gt;,并在数据良好时路由到网关以及一些将返回一些错误结果的错误处理服务否则。

    【讨论】:

    • 感谢您的信息。即使我使用路由器路由到第二个网关,如果数据不好,那么浓缩器仍然会等待回复。你如何处理这种情况
    • 就像我说的,你也必须在错误路径上返回一些东西,或者你可以在错误路径上抛出一个异常,它将被传播到丰富器的上游。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-14
    • 2014-05-04
    • 1970-01-01
    • 2011-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多