Common Retry Policies

Rate this page: 
Average: 4.2 (6 votes)

Overview

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:property></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:property></spring:property></spring:bean> </spring:property> </xyz:connector>

Adaptative retry policy

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.

Important: 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 cache="false" expected-type="javax.jms.ConnectionFactory" id="jbossConnectionFactory" jndi-name="ConnectionFactory" lookup-on-startup="false"> <jee:environment> java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1099/ </jee:environment> </jee:jndi-lookup> <spring:bean class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate" id="foreverRetryPolicyTemplate"> <spring:bean class="org.mule.modules.common.retry.policies.AdaptiveRetryPolicyTemplateWrapper" id="ThreadingPolicyTemplate"> <spring:property name="delegate" ref="foreverRetryPolicyTemplate"> </spring:property></spring:bean> </spring:bean></spring:beans> <jms:connector connectionfactory-ref="jbossConnectionFactory" name="jmsConnector" specification="1.1"> <spring:property name="retryPolicyTemplate" ref="ThreadingPolicyTemplate"> </spring:property></jms:connector>

ActiveMQ configuration (version < 5.2.0)

<spring:beans> <spring:bean class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate" id="foreverRetryPolicyTemplate"> <spring:bean class="org.mule.modules.common.retry.policies.AdaptiveRetryPolicyTemplateWrapper" id="ThreadingPolicyTemplate"> <spring:property name="delegate" ref="foreverRetryPolicyTemplate"> </spring:property></spring:bean> </spring:bean></spring:beans> <jms:activemq-connector brokerurl="${brokerUrl}?create=false" name="JmsConnector" specification="1.1"> <spring:property name="retryPolicyTemplate" ref="ThreadingPolicyTemplate"> </spring:property></jms:activemq-connector>

ActiveMQ configuration (version >= 5.2.0)

<spring:beans> <spring:bean class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate" id="foreverRetryPolicyTemplate"> <spring:bean class="org.mule.modules.common.retry.policies.AdaptiveRetryPolicyTemplateWrapper" id="ThreadingPolicyTemplate"> <spring:property name="delegate" ref="foreverRetryPolicyTemplate"> </spring:property></spring:bean> </spring:bean></spring:beans> <jms:activemq-connector brokerurl="failover:(${brokerUrl})" name="JmsConnector" specification="1.1"> <spring:property name="retryPolicyTemplate" ref="ThreadingPolicyTemplate"> </spring:property></jms:activemq-connector>

Email connector

POP3

<pop3:connector backupenabled="true" backupfolder="BACKUP" checkfrequency="10000" deletereadmessages="true" name="InputPop3Connector"> <spring:property name="retryPolicyTemplate"> <spring:bean class="org.mule.modules.common.retry.policies.ForeverRetryPolicyTemplate"> <spring:property name="sleepTime" value="60000"> </spring:property></spring:bean> </spring:property> </pop3:connector>

With our library of Cloud Connectors and repeatable integration solutions, you can rapidly create connectivity either on premise or in the cloud.

Project Owner: 
David Dossot
Contact: 
david@dossot.net
Documentation: 
#