2

私のユース ケースでは、入力を smne データで強化し、アウトバウンド エンドポイントに送信する必要があります。

強化のためのデータは、2 つの Web サービスを呼び出して取得し、応答からデータを抽出します。この抽出されたデータは、入力 XML に追加され、アウトバウンド エンドポイントに送信されます。

私が行う必要がある 2 つの Web サービス呼び出しは、互いに依存していないため、並列である必要があります。このようにして、処理時間を節約できました。

Mule のフローでこの並列処理を実現する方法を提案してください。

注: すべてのフロー制御を使用してみましたが、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>
4

1 に答える 1

2

以下は、2 つの HTTP アウトバウンド エンドポイントで fork/join を行う 1 つの方法を示す簡単な構成です。3 番目のエンドポイントを追加するには、 に設定MULE_CORRELATION_GROUP_SIZE3MULE_CORRELATION_SEQUENCE3 番目の を に設定async flow-ref3ます。

<flow name="fork">
    <vm:inbound-endpoint path="fork.in" />
    <set-property propertyName="MULE_CORRELATION_GROUP_SIZE"
        value="2" />
    <all enableCorrelation="IF_NOT_SET">
        <async>
            <set-property propertyName="MULE_CORRELATION_SEQUENCE"
                value="1" />
            <flow-ref name="parallel1" />
        </async>
        <async>
            <set-property propertyName="MULE_CORRELATION_SEQUENCE"
                value="2" />
            <flow-ref name="parallel2" />
        </async>
    </all>
</flow>

<sub-flow name="parallel1">
    <logger level="INFO" message="parallel1: processing started" />
    <http:outbound-endpoint address="..."
        exchange-pattern="request-response" />
    <logger level="INFO" message="parallel1: processing finished" />
    <flow-ref name="join" />
</sub-flow>

<sub-flow name="parallel2">
    <logger level="INFO" message="parallel2: processing started" />
    <http:outbound-endpoint address="..."
        exchange-pattern="request-response" />
    <logger level="INFO" message="parallel2: processing finished" />
    <flow-ref name="join" />
</sub-flow>

<sub-flow name="join">
    <collection-aggregator timeout="6000"
        failOnTimeout="true" />
    <combine-collections-transformer />
    <logger level="INFO"
        message="Continuing processing of: #[message.payloadAs(java.lang.String)]" />
</sub-flow>

編集: 上記の構成では、アグリゲーターは 6 秒後にタイムアウトします。これは、実際のユース ケースには短すぎる可能性があります。必要に応じて増やしてください。また、タイムアウト時に失敗するように設定されています。これは、すべてのアウトバウンド HTTP エンドポイント インタラクションが成功したわけではない場合、希望する動作ではない可能性があります。ユース ケースに基づいて決定するのはあなた次第です。

于 2012-12-29T00:10:07.453 に答える