Handling Global Exceptions in Mule

A catch exception strategy can be defined to customize the way Mule handles messages with errors. A catch exception strategy catches all exceptions thrown within its flow and processes them, thereby overriding Mule’s implicit default exception strategy.

Mule’s catch exception strategy behavior is similar to a Java catch block, except that a new exception cannot be thrown or another exception cannot be caught within a catch exception strategy.
In my previous tutorial for local catch-exception-strategy, exception strategies can be configured on a per-flow basis. This is done by defining an exception strategy at the end of each flow definition.

For global catch-exception-strategy you need to configure different exception strategies for flows that could reuse exception strategies. To configure a global exception strategy two steps are required. You need first to configure a global exception strategy and then put a reference in the desired flows.

Let’s start by configuring an exception strategy inside a flow. Let’s use a catch-exception-strategy that will catch and process all exceptions thrown in the flow

The graphical representation is shown below


mule catch exception strategy

The PriceCalculator java class source code

When you run the mule application, you will see below outputs on different inputs


mule catch exception strategy


mule catch exception strategy

Console Output

Thanks for reading.

Soumitra

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.