Exception handling 异常负载从一个流传递到由Vm端点连接的另一个流

Exception handling 异常负载从一个流传递到由Vm端点连接的另一个流,exception-handling,mule,mule-studio,Exception Handling,Mule,Mule Studio,您好,我有一个mflow文件,其中包含保存Vm入站端点的flow1。通过此Vm端点,我正在连接同一项目中其他mflow文件中存在的另一个flow2。flow2中引发了异常,我需要在flow1中捕获它。我可以在flow1中看到来自flow2的异常有效负载。但是flow1没有将其识别为异常并传递到流的其他组件,而不是将其发送到catch block。请帮助我解决此问题。我需要在主流中捕获它,即仅在flow1中。 并行流将与此流一起运行,我正在聚合这两个响应。如果其中一个流引发异常,则不应影响另一个并

您好,我有一个mflow文件,其中包含保存Vm入站端点的flow1。通过此Vm端点,我正在连接同一项目中其他mflow文件中存在的另一个flow2。flow2中引发了异常,我需要在flow1中捕获它。我可以在flow1中看到来自flow2的异常有效负载。但是flow1没有将其识别为异常并传递到流的其他组件,而不是将其发送到catch block。请帮助我解决此问题。我需要在主流中捕获它,即仅在flow1中。
并行流将与此流一起运行,我正在聚合这两个响应。如果其中一个流引发异常,则不应影响另一个并行流的执行。

调用流将不会捕获异常,因为异常不会跨端点传播

您可以将流2更改为子流或私有流(没有定义异常策略)并删除vm端点。这样,流1将捕获并处理异常

    <flow name="flow1">
        <flow-ref name="flow2" />       

        <catch-exception-strategy>
            <logger level="ERROR" message="Caught exception in flow1" />
        </catch-exception-strategy>
    </flow>

    <sub-flow name="flow2">
    ...
    </sub-flow>
    <flow name="flow1">
        ...
        <vm:outbound-endpoint exchange-pattern="request-response" address="vm://flow2" />

        <choice>
            <when expression="#[exception != null]">
                <logger level="ERROR" message="exception in flow2" />
            </when>
            <otherwise>
                <logger />
            </otherwise>
        </choice>
    </flow>

    <flow name="flow2">
        <vm:inbound-endpoint exchange-pattern="request-response" address="vm://flow2" />
        <null-component></null-component>
    </flow>

...
或者,您也可以使用过滤器或选择路由器来过滤异常

    <flow name="flow1">
        <flow-ref name="flow2" />       

        <catch-exception-strategy>
            <logger level="ERROR" message="Caught exception in flow1" />
        </catch-exception-strategy>
    </flow>

    <sub-flow name="flow2">
    ...
    </sub-flow>
    <flow name="flow1">
        ...
        <vm:outbound-endpoint exchange-pattern="request-response" address="vm://flow2" />

        <choice>
            <when expression="#[exception != null]">
                <logger level="ERROR" message="exception in flow2" />
            </when>
            <otherwise>
                <logger />
            </otherwise>
        </choice>
    </flow>

    <flow name="flow2">
        <vm:inbound-endpoint exchange-pattern="request-response" address="vm://flow2" />
        <null-component></null-component>
    </flow>

...