Responsive Ads Here

Sunday, June 3, 2018

Mule Soft: Global Exception Handling


In any mule application, we always need to handle some type or error/exceptions. Instead of creating exception handling strategy for all flows separately for each flow in application. We can create a centralized exception handling strategy that can be used anywhere into the same mule application.
Create a mule configuration file into your project. It should be at src/main/app location and
 named as global.xml. You can create it using following steps:
              Right click on your project -> click new -> click Mule Configuration File -> Fill the name and filename(global) -> click Finish.
Global.xml will have the same components as your application flow file. In this global.xml file, you can create your exception strategy that can be reused at multiple places. E.g.
<catch-exception-strategy name="globalCatch_Exception_Strategy"
            logException="true" enableNotifications="true"
when="#[exception.causedBy(com.tavant.mule.exceptions.MyCustomException)]">
</catch-exception-strategy>
The restrictions with Global Exception Handling mechanism is, we can use this approach within same project only. If we want to have a common exception handling for multiple projects in same domain or multiple projects from different domain, we have to use end point mechanism, I mean, create an exception handling application and call this application from your application using some end points.

No comments:

Post a Comment