Exception handling basics in mule

Embed Size (px)

Citation preview

Emerging Tech Series E: Knowledge Management automation of impacts

Exception Handling Basics in MULE

Messaging exception strategies

Each flow can contain only one exception strategy, however nested exception strategies are also allowed.

Each exception strategy can contain any number of message processors.

Default Exception Strategy :

No explicit configuration required

Messaging exception strategies

Handles all messaging exceptions that are thrown in any of flows.

It automatically rolls back any pending transaction and logs the exception.

if no transaction is involved, the this strategy simply logs the exception.

Custom default exception strategy is also allowed by creating a global exception strategy, then adding a reference exception strategy to a flow

Exception Handling

Supports numerous options for handling errors and allows extensive configuration of exception strategies

At high level two categories of exceptions:

1. System Exception : It is thrown at the system-level [ e.g. (i) During application start-up (ii) Connection to an external system fails ]

2. Messaging Exception : It is thrown while processing a message through a Mule flow; the normal flow execution stops, control gets transferred to exception strategy to handle it.

Note :

System Exception : Mule notifies registered listener, logs exception and if required follows reconnection strategy ( e.g. as per number and frequency to reconnect ).

Messaging Exception : Mule supports important Messaging Exception Strategy : Default, Catch, Rollback, Reference, Choice.

Image : When a message being processed through a Mule flow, it may throw an exception ( highlighted in red colour ),

As a result, the normal flow execution stops and processes transfers to the message processor sequence within the exception strategy.

Exception Handling

Note :

System Exception : Mule notifies registered listener, logs exception and if required follows reconnection strategy ( e.g. as per number and frequency to reconnect ).

Messaging Exception : Mule supports important Messaging Exception Strategy : Default, Catch, Rollback, Reference, Choice.

Image : When a message being processed through a Mule flow, it may throw an exception ( highlighted in red colour ),

As a result, the normal flow execution stops and processes transfers to the message processor sequence within the exception strategy.

Reference Exception Strategy

Reference Exception Strategy is step process

Creating a global exception strategy

Adding reference exception strategy to a flow to apply the error handling

In other words, Use a reference exception strategy to instruct a flow to employ the error handling behaviour defined by a global rollback exception strategy.