camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Serge Merzliakov <>
Subject Best Approach/Example for resubmission to JMS queue from a retry queue
Date Thu, 25 Jun 2009 07:08:03 GMT

   I would like some advice on the best way to use Camel (1.5), Spring
(2.5.6), XML and JMS (activeMQ 5.2) to RELIABLY resubmit messages from a
retry queue back to original destination queue:

        1. listen for messages arriving on from a 'retry' queue
        2. If message on 'retry' queue has been retried too many times then
move it to a 'dead letter' queue immediately.
        3. If the message can be retried, delay for X number of seconds and
then resubmit the message back to queue from which it originally came (I get
this queue from JMS property inside message).

I have read references of  how to do this but cannot find a cohesive single

My attempts so far:
** Success - I have got a sample working which use reads messages off a
queue in a transaction and if an exception is thrown the message remains on
the source queue  (this was relatively straightforward and I am very happy
with the way it works). 

** Success - If i read a message from the queue and it has been waiting for
longer than its retry interval then I send it to its destination.

** Failure - If I read a message and decide to leave it on the retry queue
(retry interval not yet reached - its too soon to try again) - I need to
throw an unneccesary exception - this creates error log entries and is
'messy'. All I want to here is stop processing the message.

I have attached my spring config as well (i have left out stuff from <bean>
root element for clarity):

    <!--  use tcp as broker is external process to this demo -->
	<bean id="jmsConnectionFactory"
		<property name="brokerURL" value="tcp://localhost:61616" />

	<cm:camelContext id="camel">
			<cm:from uri="jms:queue:input" />
			<cm:bean ref="myProcessor" beanType="Processor" />  
                        <!-- !!!! NOTE - no destination queue here - I route
using JMS property value -->

    <!--  My Processor Bean Implements the Processor Interface -->
	<bean id="myProcessor" class="cameldemo.TransformA">
		<property name="jmsTransactionManager" ref="jmsTransactionManager" />

	<bean id="jmsTransactionManager"
		<property name="connectionFactory" ref="jmsConnectionFactory" />

	<bean id="jmsConfig"
		<property name="connectionFactory" ref="jmsConnectionFactory" />
		<property name="transactionManager" ref="jmsTransactionManager" />
		<property name="transacted" value="true" />
		<property name="concurrentConsumers" value="1" />

	<bean id="activemq"
		<property name="configuration" ref="jmsConfig" />


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message