MULE
Reference Exception
Strategy
INDEX
What is exception?
Mule Exception Strategy
Reference Exception Strategy
Configure Reference Exception Strategy
Result
What is a exception?
An exception is an event, which occurs during the execution of a
program, that disrupts the normal flow of the program's instructions.
When an error occurs within a method, the method creates an object
and hands it off to the runtime system.
Mule Exception Strategy
Mule ESB provides numerous options for handling errors. Faults that occur within Mule are
referred to as exceptions; when an activity in your Mule instance fails, Mule throws an
exception. To manage these exceptions, Mule allows to configure various exception
strategies. There are five of them –
Default Exception strategy
Catch exception strategy
Roll-back exception strategy
Reference exception strategy
Choice exception strategy
In this presentation we’ll talk about Reference exception strategy.
Reference Exception Strategy
Define a reference exception strategy to refer to the error handling
parameters defined in a global catch, rollback or choice exception
strategy.
Configure Reference Exception Strategy
(Cont.)Following is the XML code for the flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8080" doc:name="HTTP Listener
Configuration"/>
<flow name="http_illustrationFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<component class="http_illustration.ErrorGenerator" doc:name="Java"/>
<exception-strategy ref="http_illustrationCatch_Exception_Strategy" doc:name="Reference Exception Strategy"/>
</flow>
<catch-exception-strategy name="http_illustrationCatch_Exception_Strategy">
<component class="http_illustration.ErrorHandler" doc:name="Java"/>
</catch-exception-strategy>
</mule>
Configure Reference Exception Strategy
The diagrammatic view will be –
Here I’ve created a flow which listens at 8080 port and then there is an
expression with wrong syntax which will throw an exception and then
the flow will transfer to Java class inside Catch exception strategy
where message “Illustration of Reference Exception strategy.” will be
returned to calling entity.
Result
 When there will be a call to this flow from browser, the message returned from
java class will there on browser.

Mule exception strategies - Reference Exception Strategy

  • 1.
  • 2.
    INDEX What is exception? MuleException Strategy Reference Exception Strategy Configure Reference Exception Strategy Result
  • 3.
    What is aexception? An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. When an error occurs within a method, the method creates an object and hands it off to the runtime system.
  • 4.
    Mule Exception Strategy MuleESB provides numerous options for handling errors. Faults that occur within Mule are referred to as exceptions; when an activity in your Mule instance fails, Mule throws an exception. To manage these exceptions, Mule allows to configure various exception strategies. There are five of them – Default Exception strategy Catch exception strategy Roll-back exception strategy Reference exception strategy Choice exception strategy In this presentation we’ll talk about Reference exception strategy.
  • 5.
    Reference Exception Strategy Definea reference exception strategy to refer to the error handling parameters defined in a global catch, rollback or choice exception strategy.
  • 6.
    Configure Reference ExceptionStrategy (Cont.)Following is the XML code for the flow: <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd"> <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8080" doc:name="HTTP Listener Configuration"/> <flow name="http_illustrationFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/> <component class="http_illustration.ErrorGenerator" doc:name="Java"/> <exception-strategy ref="http_illustrationCatch_Exception_Strategy" doc:name="Reference Exception Strategy"/> </flow> <catch-exception-strategy name="http_illustrationCatch_Exception_Strategy"> <component class="http_illustration.ErrorHandler" doc:name="Java"/> </catch-exception-strategy> </mule>
  • 7.
    Configure Reference ExceptionStrategy The diagrammatic view will be – Here I’ve created a flow which listens at 8080 port and then there is an expression with wrong syntax which will throw an exception and then the flow will transfer to Java class inside Catch exception strategy where message “Illustration of Reference Exception strategy.” will be returned to calling entity.
  • 8.
    Result  When therewill be a call to this flow from browser, the message returned from java class will there on browser.