Default Service Exception Strategy can be defined to a Model or to each individual service inside a model and it defines the functionality Mule has to perform when an unhandled exception is thrown during a message processing.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.2"
xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2" xmlns:smtp="http://www.mulesource.org/schema/mule/smtp/2.2"
xmlns:spring="www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/file/2.2 http://www.mulesource.org/schema/mule/file/2.2/mule-file.xsd
http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd
http://www.mulesource.org/schema/mule/smtp/2.2 http://www.mulesource.org/schema/mule/smtp/2.2/mule-smtp.xsd
www.springframework.org/schema/beans www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<stdio:connector name="stdioInConnector"
outputMessage="Data : " promptMessage="Enter your name : " />
<custom-transformer
class="org.mybusiness.transformers.StringToNameTransformer"
name="stringToNameTransformer" />
<model>
<default-service-exception-strategy>
<vm:outbound-endpoint path="processExceptionIN"/>
</default-service-exception-strategy>
<service name="StdioService">
<inbound>
<stdio:inbound-endpoint system="IN"
connector-ref="stdioInConnector" />
</inbound>
<outbound>
<pass-through-router>
<vm:outbound-endpoint path="processInputIN" />
</pass-through-router>
</outbound>
</service>
<service name="ProcessInput">
<inbound>
<vm:inbound-endpoint path="processInputIN">
<transformers>
<transformer ref="stringToNameTransformer" />
</transformers>
</vm:inbound-endpoint>
</inbound>
<component class="org.mybusiness.components.ProcessInputComponent" />
<outbound>
<filtering-router>
<vm:outbound-endpoint path="computeLengthIN" />
<and-filter>
<expression-filter expression="firstName='vijay'"
evaluator="jxpath" />
<expression-filter expression="lastName='san'"
evaluator="jxpath" />
</and-filter>
</filtering-router>
</outbound>
</service>
<service name="ComputeLength">
<inbound>
<vm:inbound-endpoint path="computeLengthIN" />
</inbound>
<component
class="org.mybusiness.components.ComputeLengthComponent" />
</service>
<service name="ProcessException">
<inbound>
<vm:inbound-endpoint path="processExceptionIN" />
</inbound>
<component
class="org.mybusiness.components.ExceptionHandlerComponent" />
</service>
</model>
</mule>
ExceptionHandlerComponent Class
package org.mybusiness.components;
import org.mule.message.ExceptionMessage;
public class ExceptionHandlerComponent {
public void handleException(ExceptionMessage ex) {
System.out.println("Into ExceptionHandlerComponent " + ex.getException().getMessage());
}
}
No comments:
Post a Comment