1

我正在解决如下故障安全方案。

但是在恢复流中,我无法获取由于 subflow1 或 subflow2 失败而发生的异常或 exceptionPayload。

有什么办法可以让第一个成功的路由处理器中不成功的消息处理器抛出异常。

我查看了 MuleFirstSuccessful类代码。从其中的循环中,我可以看到异常被捕获但未保存。

有没有一种方法可以扩展并拥有自己的第一次成功,这也可以为我提供例外?

<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>

请告知我是否走错了方向。有比我更好的方法吗?

4

1 回答 1

0

我得到了解决方案。骡子没有直接的解决方案。我已经覆盖了 FirstSuccessful 行为并添加了带有异常详细信息的属性。然后在第一次成功的消息处理器中访问这些属性。

catch (Exception ex)
        {
            event.getMessage().setProperty("prevError",  ex.getMessage()  , PropertyScope.INVOCATION);
            event.getMessage().setProperty("prevErrorClass",  ex.getClass()  , PropertyScope.INVOCATION);
            failed = true;
        }
于 2013-02-22T14:58:12.867 回答