97008 48403
+91 40-27177600


Using Catch Exception Strategy in MuleSoft ESB


Using Catch Exception Strategy in MuleSoft ESB

From the technical center of excellence of Massil Technologies, our technology leaders make it easy to understand the complex situations you come across in Mule ESB from the experience of Massil Technologies to have countered them in their experience of working on client projects in real time. This blog addresses how to use Catch Exception Strategy in Mule ESB. This blog is a part of series of blogs being authored and published by Massil Technologies for the benefit of the IT community globally.

What is Catch Exception Strategy?

In Mule ESB, there is a strategy adopted to customize the way messages with errors are handled. The defined strategy to catch all exception that arises within its usual flow and process them, thereby overriding Mule ESBs implicit default exception strategy. This defined strategy is termed Catch Exception Strategy in Mule ESB.

To generalize the statement made, we can compare this to Java catch block. It cannot throw a new exception or catch another exception within a catch exception strategy.

When to Use:

Using Catch Exception Strategy design a unique approach for handling any message that may contain an error. You can also use it to:

  • Evade spreading exceptions to inside connectors.
  • Evade spreading exception to regular flows via flow reference components.
  • Ensure that a transaction processed by the flow will not be rolled back when an error occurs.

Example of using Catch Exception Strategy in Mule ESB:

Let us try an example in AnyPoint Studio to understand this concept more clearly.

Step 1:

Create a project and search HTTP listener in Mule Palette and drag it to the Message flow and configure as follows:

Step 2:

Store the data in the variable which is coming from Payload as follows:

Step 3:

Let us create an Error to Caught the Catch Exception strategy. Search and Drag a variable connector from mule Palette to message flow & set the variable as given below:

Step 4:

In Http Listen, click on Error Handling to Expand. Now Search & Drag a catch exception strategy from mule Palette to message flow & keep it in Error Handling Expanded Area.

Step 5:

Drag Message Properties, keep it in catch exception strategy. Now set the http status in Message Properties as shown:

Step 6:

Keep the set payload after the message property to print the Error message.

Step 7:

Complete flow is here.

Step 8:

Run the project and after successful deployment hit some data from postman to see the results

Hope this article from Massil Technologies was useful for you. If you have any further queries on this topic, please reach out to info@massil.tech.


Leave a Reply

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

Contact Us

Get in touch with us

Scroll to top