Does anybody know how to handle Unchecked / Runtime Exceptions in MULE..??
I mean, in my java code, for a certain reason , i am “throwing an Exception” and i want Mule to detect it and route it to proper flow , where i can Log or Print that Exception.
So , What exactly should i place in my “flow” in Mule Config File to achieve that.
My Java code :
public Object xyz (Map payload) throws Exception {
if (payload.isEmpty()) {
throw new Exception ("New Exception") ;
}
}
My Mule Config file :
<flow name="APIAuthenticate">
<http:inbound-endpoint address="http://localhost:1212/jcore/authorize" transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJson" contentType="application/json" encoding="UTF-8">
<not-filter>
<wildcard-filter pattern="/favicon.ico"/>
</not-filter>
</http:inbound-endpoint>
<component class="main.java.com.abc.XYZ"/>
</flow>
Any help will be deeply appreciated..!!
Ok..i did some hit and trial and i figured out that
When the Exception is thrown, an Exception Strategy is required like default-exception-strategy OR custom-exception-strategy is required, that would route the flow to some Class that would handle it and do required Actions.
But When we Return an Exception (like below), then we can use the exception-payload-filter or choice attribute of Mule to handle it.
Please Correct me if i am wrong..??
Also if there are other answers to this question, please be kind to put them..