An exception is a difficulty that arises during the implementation of a program. An exception can occur for many different reasons, including the following :
Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner. There are different type of exception in Mule.
Let us say for example we have a file inbound and the data are send as form of mail.
So <default-connector-exception-strategy/> automatically takes care of the exception that is taking care of it.
It throws exception for all Services on behalf of it.
<model name="randomGeneratorModel">
<default-service-exception-strategy/>
<service name="RandomIntegerGenerator">
<inbound>
<vm:inbound-endpoint path="RIG.In" />
</inbound>
<component>
<no-arguments-entry-point-resolver>
<include-entry-point method="nextInt"/>
</no-arguments-entry-point-resolver>
<singleton-object class="java.util.Random" />
</component>
</service>
..
</model>
Here is the following example for exception handling
Not always we send all excpetions to get handled internally in some cases we may need our own logic to handle exceptions.
For (ex)
<model name="randomGeneratorModel">
<default-connector-exception-strategy>
<jms:outbound-endpoint queue="transport-errors"/>
</default-connector-exception-strategy>
<default-service-exception-strategy>
<jms:outbound-endpoint queue="business-errors"/>
</default-service-exception-strategy>
<service name="RandomIntegerGenerator">
<inbound>
<vm:inbound-endpoint path="RIG.In" />
</inbound>
<component>
<no-arguments-entry-point-resolver>
<include-entry-point method="nextInt"/>
</no-arguments-entry-point-resolver>
<singleton-object class="java.util.Random" />
</component>
</service>
In this type of strategy, failure may cause at any point of time and you need to re-execute the use case for the defined number of times it may be 1, 2, …, n.
Consider we are having a case in which we are not able to connect to server now we want to perform this action for 5 times and if we do not get succeeded in those attempts then we will try to get connected to another server.
So for Looped execution we will write
<rollback-exception-strategy maxRedeliveryAttempts="3">
and for maximum exceeded attempts we need to execute
<on-redelivery-attempts-exceeded>
For ex.
<jms:activemq-connector name="activeMQ"/>
<flow>
<jms:inbound-endpoint queue="in">
<jms:transaction action="ALWAYS_BEGIN"/>
</jms:inbound-endpoint>
<processor ref="processor"/>
<rollback-exception-strategy maxRedeliveryAttempts="3">
<on-redelivery-attempts-exceeded>
<jms:outbound-endpoint queue="dlq">
<jms:transaction action="ALWAYS_JOIN"/>
</jms:outbound-endpoint>
</on-redelivery-attempts-exceeded>
</rollback-exception-strategy>
</flow>
http://www.mulesoft.org/documentation/display/current/Rollback+Exception+Strategy+Behavior
http://www.mulesoft.org/documentation/display/current/Rollback+Exception+Strategy+Documentation
联系客服