2013-02-11 59 views
1

我正在解決如下的故障安全場景。提取FirstSuccessful路由消息處理器中不成功的消息處理器引發的異常

但是在恢復流程中,我無法獲取由於subflow1或subflow2失敗而發生的異常或exceptionPayload。

有什麼辦法可以得到第一個成功的路由處理器中不成功的消息處理器拋出的異常。

我已經看過Mule FirstSuccessful類代碼。從它的循環中,我可以看到異常被捕獲但未保存。

有沒有一種方法可以擴展並擁有我自己的第一次成功,這也可以爲我提供例外情況?

<flow name="main_flow" > 
    .... 
    .... 
    <first-successful> 
     <flow-ref name="subflow_1" /> 
     <flow-ref name="recoveryFlow1" /> 
    </first-successful> 
    .... 
    .... 
    <first-successful> 
     <flow-ref name="subflow_2" /> 
     <flow-ref name="recoveryFlow2" /> 
    </first-successful> 
    .... 
    .... 
</flow> 

<sub-flow name="subflow_1"> 
    .... 
    .... 
    <out-bound call to web-service /> 
    .... 
    .... 
</sub-flow> 

<sub-flow name="subflow_2"> 
    .... 
    .... 
    <out-bound call to web-service /> 
    .... 
    .... 
</sub-flow> 

<sub-flow name="revoceryFlow1" > 
    <process communication based on the exception thrown by previous unsuccessful sub-flow 1> 
    <some more processing so that the remaining main flow is not impacted because of the failue of the subflow 1 > 
</sub-flow> 

<sub-flow name="revoceryFlow2" > 
    <process communication based on the exception thrown by previous unsuccessful sub-flow 2> 
    <some more processing so that the remaining main flow is not impacted because of the failue of the subflow 2 > 
</sub-flow> 

請指教,如果我走錯了方向。有沒有比我更好的方法?

回答

0

我得到了解決方案。 騾子沒有直接的解決方案。 我已覆蓋FirstSuccessful行爲並添加了具有異常詳細信息的屬性。這些屬性然後在第一次成功的內部的下一個消息處理器中被訪問。

catch (Exception ex) 
     { 
      event.getMessage().setProperty("prevError", ex.getMessage() , PropertyScope.INVOCATION); 
      event.getMessage().setProperty("prevErrorClass", ex.getClass() , PropertyScope.INVOCATION); 
      failed = true; 
     }