gpt4 book ai didi

java - 提取 FirstSuccessful 路由消息处理器中不成功消息处理器抛出的异常

转载 作者:行者123 更新时间:2023-12-01 04:51:49 26 4
gpt4 key购买 nike

我正在解决如下的故障安全场景。

但是在恢复流程中,我无法获取由于子流1或子流2失败而发生的异常或异常Payload。

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

我研究了 Mule FirstSuccessful 类代码。从其中的循环中,我可以看到异常被捕获但没有保存。

有没有一种方法可以让我扩展并拥有自己的第一个成功的方法,这也可以为我提供异常(exception)?

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

如果我走错方向,请指出。还有比我更好的方法吗?

最佳答案

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

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

关于java - 提取 FirstSuccessful 路由消息处理器中不成功消息处理器抛出的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14821615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com