In this scenario, we will examine the effects of an error occurring in the child flow. The source flow will call the child flow and passes the Mule event to it. An error occurs in the event processor labeled E, and subsequent processors are not executed. Child flow has an on error propagate scope, and calling flow has an on error continue scope present in them.
When an error happens at processor E, the Event is passed to the on error propagate scope of child flow. After the scope is executed, the error is rethrown in the calling flow without executing further processors in the calling flow and handled by calling flow’s On error continue scope. Further processors of the calling scope are suspended, and a success message with payload is returned to the HTTP listener.
Debug the application to understand how the error is handled.
Once your application is successfully deployed, Go to Postman or Advance rest-client and send a request to the API. As seen in the exhibit below, the payload is not set yet.
Moving one step forward, the payload is set to “Max Mule” (exhibit below)
With another step, the flow reference will pass the Mule event to the child flow. (exhibit below)
When another step is taken, the error is thrown by the “is null” validation processor(exhibit below)
with the next step, the Mule event is passed is flow level error handler(exhibit below)
The payload is modified by the processor in on error propagate scope with the next step. (exhibit below)
When we come out of the error scope, the remaining flow is suspended, and the Mule event is returned to the calling flow with the error object. (exhibit below)
As there is an error in the calling flow, the Mule event is passed to the flow level error handler of the calling flow. (exhibit below)
The payload is modified by the processor in on error continue scope with the next step. (exhibit below)
With the next step, the payload is logged, remaining processors of the flow are suspended, and a “success” response with payload is sent back to the HTTP listener, which can be seen in the Postman’s response.
Error handling scenario 5
In this scenario, we will examine the effects of an error occurring in the child flow. The source flow will call the child flow and passes the Mule event to it. An error occurs in the event processor labeled E, and subsequent processors are not executed. Child flow has an on error continue scope, and calling flow has an on error continue or propagate scope(both will work in the same manner)present in them.
When an error happens at processor E, the Event is passed to the on error continue scope of child flow. After the scope is executed, the error is not rethrown in the calling flow without executing further processors of the calling scope are not suspended as the error response is not returned by child flow. A success message with payload is returned to the HTTP listener once calling flow execution ends.
Debug the application to understand how the error is handled.
Once your application is successfully deployed, Go to Postman or Advance rest-client and send a request to the API. As seen in the exhibit below, the payload is not set yet.
Moving one step forward, the payload is set to “Max Mule” (exhibit below)
With another step, the flow reference will pass the Mule event to the child flow. (exhibit below)
When another step is taken, the error is thrown by the “is null” validation processor(exhibit below)
with the next step, the Mule event is passed is flow level error handler(exhibit below)
The payload is modified by the processor in on error propagate scope with the next step. (exhibit below)
When we come out of the error scope, the remaining flow is suspended, and the Mule event is returned to the calling flow without the error object. (exhibit below)
As there is NO error in the calling flow, the Mule event is not passed to the flow level error handler of the calling flow. hence it doesn’t matter if it is on error continue or on error propagation scope, the parent flow will execute fully, and a success message is returned with payload to HTTP Listener. (exhibit below)