Camel RetryPolicy Configuration Question
Issue
I have configured a Camel route to transfer files from a directory to an ActiveMQ queue.
public class DemoHelperRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
onException(JmsException.class, ConnectException.class)
.routeId("ConnectionExceptionRoute")
.handled(true)
.log(LoggingLevel.ERROR, "Connection Error")
.maximumRedeliveries(5)
.redeliveryDelay(1000)
.backOffMultiplier(2)
.useExponentialBackOff()
.maximumRedeliveryDelay(60000)
.log(LoggingLevel.DEBUG, "Rolling back!")
.rollback();
errorHandler(defaultErrorHandler()
.maximumRedeliveries(20).redeliveryDelay(7000).retryAttemptedLogLevel(LoggingLevel.INFO));
from("file:{{directory.property}}?delete=true&readLock=markerFile&delay=5000")
.log("Passing File")
.transacted("PROPAGATION_REQUIRED")
.setHeader("FILE_TYPE", constant("MYTYPE"))
.setHeader("MSG_ID", constant("55"))
.to("activemq:{{MY.QUEUE}}");
}
}
My Camel context file looks like this:
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>
<!-- This is the default behavior. -->
<bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager"/>
</bean>
<bean id="PROPAGATION_REQUIRES_NEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager"/>
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="jmsConnectionFactory"></property>
<property name="transacted" value="true"/>
<property name="transactionManager" ref="jmsTransactionManager"/>
</bean>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${jms.broker.url}"/>
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1" />
<property name="redeliveryDelay" value="10000" />
</bean>
</property>
</bean>
I have several other routes between a variety of different endpoints in the application which require redelivery configuration and are behaving as expected. However, this particular route type (from file to queue) does not seem to follow any of the redelivery policies I have configured. When I bring down the ActiveMQ broker, the route attempts to redeliver the file every 6 seconds.:
>10:54:09,979 | INFO | C_demo%5 | route6 | 105 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | Passing File
>10:54:11,072 | WARN | C_demo%5 | TransactionErrorHandler | 105 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | Transaction rollback (0x5757baa8) redelivered(unknown) for (MessageId: ID-3668-1385561154291-4-1 on ExchangeId: ID-3668-1385561154291-4-2) caught: Could not create JMS transaction; nested exception is javax.jms.JMSException: Could not connect to broker URL: <URL>. Reason: java.net.ConnectException: Connection refused: connect
>10:54:11,072 | WARN | C_demo%5 | GenericFileOnCompletion | 105 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy@789d315e for file: GenericFile[<file_location>]
>10:54:16,088 | INFO | C_demo%5C | route6 | 105 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | Passing File
>10:54:17,088 | WARN | C_demo%5C | TransactionErrorHandler | 105 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | Transaction rollback (0x5757baa8) redelivered(unknown) for (MessageId: ID-3668-1385561154291-4-3 on ExchangeId: ID-3668-1385561154291-4-4) caught: Could not create JMS transaction; nested exception is javax.jms.JMSException: Could not connect to broker URL: <URL>. Reason: java.net.ConnectException: Connection refused: connect
>10:54:17,088 | WARN | C_demo%5 | GenericFileOnCompletion | 105 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | Rollback file strategy: org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy@789d315e for file: GenericFile[<file_location>]
Environment
Red Hat JBoss Fuse 6.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.