Exception Handling
home
Illustrates how to leverage the Mule Exception framework to catch, classify, and handle errors in Mule flows. This is Part 1 of a series for exception handling.
Assumptions
This document describes the details of the example within the context of Anypoint Studio. Where appropriate, the XML configuration accompanies the Studio interface
screenshots. This document assumes that you are familiar with Mule Runtime, the Anypoint Studio interface.
Example
In this example we use a JMS queue to initiate a Mule flow to trigger different classes of exceptions. Depending on the type of exception (retriable or non-retriable) we configure the exception handling strategy to process accordingly.
Set Up and Run the Example
As with other examples, you can create template applications straight out of the box in Anypoint Studio. You can tweak the configurations of these use case-based examples to create your own customized applications in Mule.
ActiveMQ Setup
This example relies on an ActiveMQ instance to connect to. For more details on how to setup ActiveMQ, please refer to ActiveMQ documentation located here.
You can use a different JMS broker if you have one available, some additional reconfiguration of the JMS connector is required. You also need to download the ActiveMQ jar library and save into src/main/app/lib/activemq-all-5.13.4.jar.
Modify the mule-app.properties file to update the following properties to match your environment
Property | Description |
---|---|
activemq.brokerurl | The broker url for Active MQ. Format should be tcp://localhost:61616 |
activemq.username | User required for connecting to ActiveMQ |
activemq.password | Password required for the user used for connecting to ActiveMQ |
Database Setup
This example intentionally does not require a database to simulate a unavailable exception to highlight what happens when a database becomes unavailable. However a SQL script for a MySQL database is provided for completeness. Even though we are not using the database connector, a JAR library is required for runtime binding. Download the MySQL jar library and save into src/main/app/lib/mysql-connector-java-5.1.38.jar