While consuming message from JMS queue I wish to decide whether consuming process is success or fail, In case of failure I wish that activemq redeliver the message again after some time like 1 minute. Later on based on delivery count I may send it to DLQ.
I found examples to achieve same with java code like session with different acknowledgement mode or making the session transacted but could not get how to achieve same with blueprint file.
<reference id="testIdempotencyStore"
interface="javax.sql.DataSource"
filter="(osgi.jndi.service.name=TestContext)">
</reference>
<bean id="simulatorMessages" class="org.apache.camel.processor.idempotent.jdbc.JdbcMessageIdRepository">
<argument ref="testIdempotencyStore" />
<argument value="jmsTest" />
</bean>
<reference id="txMgr" interface="javax.transaction.TransactionManager" />
<bean id="xaConnectionFactory" class="org.apache.activemq.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="${activemq.url}" />
<property name="watchTopicAdvisories" value="false" />
<property name="userName" value="${activemq.user}" />
<property name="password" value="${activemq.password}" />
<property name="redeliveryPolicy" >
<bean class="org.apache.activemq.RedeliveryPolicy" >
<property name="maximumRedeliveries" value="0" />
</bean>
</property>
</bean>
<bean id="jcaConnectionFactory" class="org.apache.activemq.jms.pool.JcaPooledConnectionFactory"
init-method="start" destroy-method="stop">
<property name="transactionManager" ref="txMgr"/>
<property name="maxConnections" value="10" />
<property name="name" value="amq" />
<property name="connectionFactory" ref="xaConnectionFactory"/>
</bean>
<bean id="jmsTxConf" class="org.apache.activemq.camel.component.ActiveMQConfiguration">
<property name="connectionFactory" ref="jcaConnectionFactory" />
<property name="requestTimeout" value="10000" />
<property name="transactionTimeout" value="30" />
<property name="cacheLevelName" value="CACHE_NONE" />
</bean>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="configuration" ref="jmsTxConf" />
</bean>
<camelContext id="TestContext-jms-dispatcher" trace="false" xmlns="http://camel.apache.org/schema/blueprint" >
<route id="externalNotificationsDispatchRoute" >
<from uri="activemq:queue:{{vqueue.name}}" />
<idempotentConsumer messageIdRepositoryRef="simulatorMessages">
<header>customId</header>
<to uri="vm:notificationConsumer" />
</idempotentConsumer>
</route>
</camelContext>
If you haven't done so already, read through this chapter to learn more about how JMS XA Transactions work in JBoss Fuse.
You're missing the Spring
PlatformTransactionManager
and a few other things. Here's an example of a configuration that should work: