Hi everyone,
my route receives messages from a durable activemq topic and writes
these to a database.
Now I tried to enhance the route with transactions, that worked so far,
but I also want
to configure the Transactional Error Handler to retry forever and not
only six times.
I configured transaction based on the documentation in camel-context.xml:
<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="tcp://xxxx" />
</bean>
<bean id="jmsTransactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
<bean id="jmsConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="jmsConnectionFactory" />
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="transacted" value="true" />
<property name="concurrentConsumers" value="1" />
</bean>
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="configuration" ref="jmsConfig" />
</bean>
<bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
<property name="transactionManager" ref="jmsTransactionManager" />
<property name="propagationBehaviorName"
value="PROPAGATION_REQUIRED"/>
</bean>
And I use the Java DSL to build my route:
getContext().addComponent("activemq",
bean(ActiveMQComponent.class, "activemq"));
SpringTransactionPolicy required =
bean(SpringTransactionPolicy.class,
"PROPAGATION_REQUIRED");
TransactionErrorHandlerBuilder builder =
transactionErrorHandler(required);
RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
redeliveryPolicy.setMaximumRedeliveries(-1);
builder.setRedeliveryPolicy(redeliveryPolicy);
errorHandler(builder);
from("activemq:topic:TransactionTest2?clientId=test2&durableSubscriptionName=test2")
.policy(required)
.process(new Processor(){
@Override
public void process(Exchange exchange) throws
Exception {
// After six times the message is dropped
exchange.setException(new Exception("Test
exception ..."));
}})
.process(...);
For me it looks like it still uses the Dead Letter Channel Error Handler and
my call the errorHandler does not change the error handling.
Thanks for your help,
Jörn