Common Retry Policies
The Common Retry Policies is a module containing community built and maintained implementations of retry policies.
These policies are compatible with Mule 2.1.2 or above.
Forever retry policy
This policy retries for ever and waits for a configured amount of time (in milliseconds) between retries.
<xyz:connector name="xyzConnector">
<spring:property name="retryPolicyTemplate">
<spring:bean class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate">
<spring:property name="sleepTime" value="5000"/>
</spring:bean>
</spring:property>
</xyz:connector>
Exhausting retry policy
This policy retries for a configured amount of attempts and waits for a configured amount of time (in milliseconds) between retries.
<xyz:connector name="xyzConnector">
<spring:property name="retryPolicyTemplate">
<spring:bean class="org.mule.modules.common.retry.policies.ExhaustingRetryPolicyTemplate">
<spring:property name="sleepTime" value="5000"/>
<spring:property name="retryLimit" value="10"/>
</spring:bean>
</spring:property>
</xyz:connector>
Adaptative retry policy
 | Please report your configuration bits to help beef up this documentation page! |
This retry policy template that uses an adaptative strategy for executing it: if Mule is not started, it will execute it in a different thread, if Mule is started it will execute it in the current thread.
The idea is to allow Mule to start with a failed connector by not holding the bootstrap thread but, after startup, to hold all receiver/dispatcher threads until the reconnection happens.
 | Behind the scene, this retry policy uses one thread from Mule's Server WorkManager per failed connector. If you use it on many connectors, be sure to size its pool accordingly.
|
Here are the connector configurations with which the retry policy has been tested.
JMS Connector
JBossMQ configuration
<spring:beans>
<jee:jndi-lookup id="jbossConnectionFactory" jndi-name="ConnectionFactory"
lookup-on-startup="false" cache="false" expected-type="javax.jms.ConnectionFactory">
<jee:environment>
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp: </jee:environment>
</jee:jndi-lookup>
<spring:bean id="foreverRetryPolicyTemplate" class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate" />
<spring:bean id="ThreadingPolicyTemplate"
class="org.mule.modules.common.retry.policies.AdaptiveRetryPolicyTemplateWrapper">
<spring:property name="delegate" ref="foreverRetryPolicyTemplate" />
</spring:bean>
</spring:beans>
<jms:connector name="jmsConnector" specification="1.1" connectionFactory-ref="jbossConnectionFactory">
<spring:property name="retryPolicyTemplate" ref="ThreadingPolicyTemplate" />
</jms:connector>
ActiveMQ configuration (version < 5.2.0)
<spring:beans>
<spring:bean id="foreverRetryPolicyTemplate" class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate" />
<spring:bean id="ThreadingPolicyTemplate"
class="org.mule.modules.common.retry.policies.AdaptiveRetryPolicyTemplateWrapper">
<spring:property name="delegate" ref="foreverRetryPolicyTemplate" />
</spring:bean>
</spring:beans>
<jms:activemq-connector name="JmsConnector" brokerURL="${brokerUrl}?create=false" specification="1.1">
<spring:property name="retryPolicyTemplate" ref="ThreadingPolicyTemplate" />
</jms:activemq-connector>
ActiveMQ configuration (version >= 5.2.0)
<spring:beans>
<spring:bean id="foreverRetryPolicyTemplate" class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate" />
<spring:bean id="ThreadingPolicyTemplate"
class="org.mule.modules.common.retry.policies.AdaptiveRetryPolicyTemplateWrapper">
<spring:property name="delegate" ref="foreverRetryPolicyTemplate" />
</spring:bean>
</spring:beans>
<jms:activemq-connector name="JmsConnector" brokerURL="failover:(${brokerUrl})" specification="1.1">
<spring:property name="retryPolicyTemplate" ref="ThreadingPolicyTemplate" />
</jms:activemq-connector>
Email connector
POP3
<pop3:connector name="InputPop3Connector" checkFrequency="10000" deleteReadMessages="true" backupEnabled="true" backupFolder="BACKUP">
<spring:property name="retryPolicyTemplate">
<spring:bean
class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate">
<spring:property name="sleepTime" value="60000" />
</spring:bean>
</spring:property>
</pop3:connector>