异步块使异步内的所有流引用?

时间:2014-07-10 10:34:08

标签: mule

考虑以下情况: 我有一个web服务,开始从源中导入东西。我希望在接听电话后立即向呼叫者返回200 OK。 需要以正确的顺序执行的流程很少。

<flow name="startImport" >
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
        <async>
            <flow-ref name="Country" />
            <flow-ref name="Account" />
            <flow-ref name="Contact" />
        </async>
</flow>

嗯,这不起作用,因为所有流程都会立即执行。

如何将它包装在另一个这样的流程中?

<flow name="startImport" >
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
        <async>
            <flow-ref name="startImport2" />
        </async>
</flow>

<flow name="startImport2" processingStrategy="synchronous" >
        <processor-chain>
            <flow-ref name="Country" />
            <flow-ref name="Account" />
            <flow-ref name="Contact" />
        </processor-chain>
</flow>

不,结果仍然相同!

如何阻止async-block使所有其他flow-refs也变为异步?我只希望第一次调用以异步方式启动!

2 个答案:

答案 0 :(得分:3)

通过flow-ref调用的私人流量将获取飞行中事件的同步性。

要更改此设置,您可以更改要同步执行的流的processingStrategy。例如:

<flow name="Country" processingStrategy="synchronous">

</flow>

答案 1 :(得分:0)

好吧,我最终删除了流引用并改为使用vm-endpoints,如下所示:

<flow name="startImport" >
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="startImport"/>
        <async>
            <vm:outbound-endpoint exchange-pattern="one-way"  doc:name="VM" path="import-all.service.in"/>
        </async>
</flow>

<flow name="startImport2" processingStrategy="synchronous" >
      <vm:outbound-endpoint exchange-pattern="one-way"  doc:name="VM" path="import-all.service.in"/>
      <flow-ref name="Country" />
      <flow-ref name="Account" />
      <flow-ref name="Contact" />
</flow>

现在它的工作方式就像我希望它能够正常工作一样,它会从调用中快速返回并让异步流程完成繁重的工作。