2014-03-12 26 views
0

改寫了問題 - 我有一個要求,在單個mule流內,我必須進行3個Web服務調用(S1,S2,S3)。併發處理騾流內的Web服務調用

<flow> 
<Service1> 
<Service2> 
<Service3> 
</flow> 

我的要求是調用服務1 &等待它完成(或處理錯誤,如果不成功&回)再火客服2 &服務3兼任/同步。我想等待Service1的響應,因爲我對Service2的呼叫& Service3使用來自Service1的部分響應作爲輸入。所以我的騾子流應該在Service2服務3之前等待Service1的響應。但是如果&當Service1成功時,它應該同時調用Service2 & Service3。 即使Service2的其中一個服務3失敗,我仍希望繼續進行此流程的調用者並且不會失敗/錯誤。

任何類型的示例代碼/鏈接都會很好。

+0

你的問題是有點混亂。它是並行還是順序運行(一個接一個)? – user1760178

回答

0

如果您想要一個接一個地調用3個服務,並且任何服務失敗都不應影響剩餘流量,則可以嘗試以下類型的設計。

<flow name="main_flow"> 
    <flow-ref name="private_flow_call_to_service_1"></flow-ref> 
    <flow-ref name="private_flow_call_to_service_2"></flow-ref> 
    <flow-ref name="private_flow_call_to_service_3"></flow-ref> 
</flow> 

<flow name="private_flow_call_to_service_1" processingStrategy="synchronous"> 
    <!-- call service 1 --> 
    <catch-exception-strategy> 
     <!-- Catch and handle any error or failure while making call to service 1 --> 
    </catch-exception-strategy> 
</flow> 

<flow name="private_flow_call_to_service_2" processingStrategy="synchronous"> 
    <!-- call service 2 --> 
    <catch-exception-strategy> 
     <!-- Catch and handle any error or failure while making call to service 2 --> 
    </catch-exception-strategy> 
</flow> 

<flow name="private_flow_call_to_service_3" processingStrategy="synchronous"> 
    <!-- call service 3 --> 
    <catch-exception-strategy> 
     <!-- Catch and handle any error or failure while making call to service 3 --> 
    </catch-exception-strategy> 
</flow> 

希望這會有所幫助。