1
votes

Hi i have a mflow file that contains flow1 in which Vm inbound endpoint is kept.Through this vm endpoint i am connecting the other flow2 which is present in onother mflow file in the same project.An exception has been thrown in flow2 and i need to catch it in flow1. I can see the exception payload in flow1 which is coming from flow2.But flow1 is not recognizing it as an exception and passing to the other components of flow instead of sending it to catch block.help me in soving this issue.I need to catch it in main flow i.e flow1 only. Parallel flow will be running along with this flow and i am aggregating both the responses.If one of the flow throws exception it shouldnt effect the execution of another parallel flow.

1

1 Answers

1
votes

The calling flow will not catch the exception because exceptions are not propagated across endpoints.

You could change flow 2 to a sub-flow or a private flow(without an exception strategy defined) and remove the vm-endpoint. This way flow 1 will catch and handle the exception.

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

Or alternatively you could use a filter or choice router to filter for the exception.

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