如何进行并行出站呼叫

时间:2012-12-27 19:56:09

标签: java parallel-processing mule flow

我的用例需要使用smne数据丰富我的输入并将其发送到出站端点。

通过调用两个Web服务然后从回复中提取数据来获得用于丰富的数据。 这些提取的数据被丰富到我的输入XML中并发送到出站端点。

我需要进行的两个Web服务调用需要并行,因为它们不依赖于另一个。这样我就可以节省处理时间。

请建议我如何在Mule的流程中实现这种并行处理。

注意:我尝试过使用ALL流控制,但似乎是按顺序调用Web服务(子流)。

以下是我的抽象流程。

<flow name="mainFlow">
    <inbound-endpoint> .....

    <some validation>

    <setting some flow variables>

    <!-- Now make calls to the sub-flows which has some processing of the input and make some web-service calls -->
    <all>
        <flow-ref name="myFlow1" />
        <flow-ref name="myFlow2" />
        <flow-ref name="myFlow3" />
    </all>

    <enrich the input with the data obtained from the output of the above three flows>

    <outbound-endpoint>
</flow>



<flow name="myFlow1">
    <some transformer to transform the payload provided >

    < the tran sformed payload is passed as input to the web-service call>

    <http:outbound-endpoint ...>

    <transform the reply from the web-service call>
</flow>



<flow name="myFlow2">
    <some transformer to transform the payload provided >

    < the tran sformed payload is passed as input to the web-service call>

    <http:outbound-endpoint ...>

    <transform the reply from the web-service call>
</flow>



<flow name="myFlow3">
    <some transformer to transform the payload provided to it>

    < the tran sformed payload is passed as input to the web-service call>

    <http:outbound-endpoint ...>

    <transform the reply from the web-service call>
</flow>

1 个答案:

答案 0 :(得分:2)

这是一个简单的配置,显示了使用两个HTTP出站端点进行fork / join的一种方法。要添加第三个端点,请将MULE_CORRELATION_GROUP_SIZE设置为3,将第三个MULE_CORRELATION_SEQUENCE的{​​{1}}设置为async flow-ref

3

编辑:在上面的配置中,聚合器在6秒后超时。这对于您的实际用例来说可能太短了:根据您的需要增加。此外,它设置为超时失败,这可能不是您希望的行为,以防所有出站HTTP端点交互成功:您可以根据您的用例来决定。