Reputation: 6647
I am trying to create a fail-safe scenario in my flow.
My flow looks like below. It involves some sub-flows which intern have call to web-services. In any scenario if one of the web-service is not available the connection-refused exception is thrown and the whole processing stops.
Instead I want a fail-safe scenario where the flow should continue with the next sub-flows even if the current out-bound call fails.
Is there any message processor or flow-control processor that could help acheive this behaviour in Mule.
Given below is my abstract flow
<flow name="main_flow" >
....
....
<flow-ref name="subflow_1" />
....
....
<flow-ref name="subflow_2" />
....
....
<flow-ref name="subflow_3" />
....
....
</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="subflow_3">
....
....
<out-bound call to web-service />
....
....
</sub-flow>
Upvotes: 0
Views: 180
Reputation:
You can achive the fail-safe behaviour with the flows.
<flow name="main_flow" >
....
....
<flow-ref name="flow_1" />
....
....
<flow-ref name="flow_2" />
....
....
<flow-ref name="flow_3" />
....
....
</flow>
<flow name="flow_1" processingStrategy="synchronous" >
....
....
<out-bound call to web-service />
....
<catch-exception-strategy >
.... Your FailSafe code to recover. Also you will have the exception here.
</catch-exception-strategy>
</flow>
This way you can schieve the fail safe behaviour using the flows.
Happy Coding :)
Upvotes: 1
Reputation: 33413
For each web-service call, use a first-successful
router, having your web-service call as the first child and the fall-back mechanism as the second one.
Upvotes: 1
Reputation: 4551
One hack could be to store the payload in a variable, have a <catch-exception-strategy>
block which will catch your web-service invoke exception, use <set-payload>
to overwrite the current payload and then call sub-flow2
manually from catch-exception
flow of sub-flow1
Upvotes: 1