You should remove the Camel error handler, and let the broker do the redelivery.
Don't do both.

A message broker can also be configured to perform redelivery of
messages, and it has a dead letter queues etc.

If you use ActiveMQ read and their links
http://activemq.apache.org/redelivery-policy.html
http://activemq.apache.org/message-redelivery-and-dlq-handling.html

And possible the Camel docs for the transactional client EIP (eg transaction)
http://camel.apache.org/transactional-client.html

On Thu, Aug 23, 2012 at 3:30 PM, towe <tobias.westerb...@cubeia.com> wrote:
> I am using transacted mode. But if I stop Camel during redelivery while the
> queue on B is down the message gets removed from the queue and is gone when
> I restart.
>
> To simulate an error I have a dummy consumer that throws an exception, but
> the problem is the same if I have a remote queue that is shut down.
>
> This is my Camel route (some beans left out for clarity):
>
>   [...]
>
>   <bean id="jmsConfig"
>      class="org.apache.camel.component.jms.JmsConfiguration">
>      <property name="connectionFactory" ref="poolConnectionFactory"/>
>      <property name="transactionManager" ref="jmsTransactionManager"/>
>      <property name="transacted" value="true"/>
>      <property name="concurrentConsumers" value="1"/>
>   </bean>
>
>   <bean id="jmsTransactionManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
>     <property name="connectionFactory" ref="poolConnectionFactory" />
>   </bean>
>
>   <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>       <property name="configuration" ref="jmsConfig"/>
>   </bean>
>
>   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>
>     <errorHandler id="camelErrorHandler">
>       <redeliveryPolicy maximumRedeliveries="-1" />
>     </errorHandler>
>
>     <onException>
>         <exception>java.lang.Exception</exception>
>         <rollback  markRollbackOnly="true" />
>     </onException>
>
>     <route errorHandlerRef="camelErrorHandler"
> shutdownRunningTask="CompleteCurrentTaskOnly">
>       <from uri="activemq:queue:events" />
>       <transacted ref="PROPAGATION_REQUIRED"/>
>       <to uri="bean:dummyConsumer?method=onMessage(${body})"/>
>     </route>
>   </camelContext>
>   [...]
>
>
> When shutting down I get the log below. The log basically says that it is
> waiting for an in-flight message left, then when it times out it forces a
> shutdown.
>
> --------------------------------------
> 2012-08-23 15:19:47,132 INFO  org.apache.camel.impl.DefaultShutdownStrategy
> - Waiting as there are still 1 inflight and pending exchanges to complete,
> timeout in 1 seconds.
> 2012-08-23 15:19:47,661 DEBUG org.apache.camel.processor.SendProcessor -
>>>>> Endpoint[bean://dummyConsumer?method=onMessage($%7Bbody%7D)]
> Exchange[JmsMessage[JmsMessageID:
> ID:tjock-xxl-41399-1345727978381-1:1:1:1:1]]
>
> --- DUMMY CONSUMER, message: message 1345727978573
>
> 2012-08-23 15:19:47,663 DEBUG org.apache.camel.processor.DefaultErrorHandler
> - Failed delivery for (MessageId: ID:tjock-xxl-41399-1345727978381-1:1:1:1:1
> on ExchangeId: ID-tjock-xxl-57097-1345727966790-0-1). On delivery attempt: 9
> caught: java.lang.RuntimeException: test error
> 2012-08-23 15:19:47,663 DEBUG org.apache.camel.processor.DefaultErrorHandler
> - Redelivery delay calculated as 1000
> 2012-08-23 15:19:47,663 DEBUG org.apache.camel.processor.RedeliveryPolicy -
> Sleeping for: 1000 millis until attempting redelivery
> 2012-08-23 15:19:48,130 WARN  org.apache.camel.impl.DefaultShutdownStrategy
> - Timeout occurred. Now forcing the routes to be shutdown now.
> 2012-08-23 15:19:48,130 WARN  org.apache.camel.impl.DefaultShutdownStrategy
> - Interrupted while waiting during graceful shutdown, will force shutdown
> now.
> 2012-08-23 15:19:48,663 DEBUG org.apache.camel.processor.SendProcessor -
>>>>> Endpoint[bean://dummyConsumer?method=onMessage($%7Bbody%7D)]
> Exchange[JmsMessage[JmsMessageID:
> ID:tjock-xxl-41399-1345727978381-1:1:1:1:1]]
>
> --- DUMMY CONSUMER, message: message 1345727978573
>
> 2012-08-23 15:19:48,665 WARN
> org.apache.camel.spring.spi.TransactionErrorHandler - Transaction rollback
> (0x8996666) redelivered(false) for (MessageId:
> ID:tjock-xxl-41399-1345727978381-1:1:1:1:1 on ExchangeId:
> ID-tjock-xxl-57097-1345727966790-0-1) caught: java.lang.RuntimeException:
> test error
> 2012-08-23 15:19:48,666 DEBUG org.apache.activemq.ActiveMQSession -
> ID:tjock-xxl-46934-1345727966509-3:1:1 Transaction Rollback,
> txid:TX:ID:tjock-xxl-46934-1345727966509-3:1:1
> 2012-08-23 15:19:48,666 DEBUG org.apache.activemq.TransactionContext -
> Rollback: TX:ID:tjock-xxl-46934-1345727966509-3:1:1 syncCount: 2
> 2012-08-23 15:19:48,668 DEBUG
> org.apache.activemq.transaction.LocalTransaction - rollback:
> TX:ID:tjock-xxl-46934-1345727966509-3:1:1 syncCount: 2
> 2012-08-23 15:19:48,669 DEBUG org.apache.activemq.ActiveMQMessageConsumer -
> remove: ID:tjock-xxl-46934-1345727966509-3:1:1:12,
> lastDeliveredSequenceId:31
> 2012-08-23 15:19:48,669 DEBUG org.apache.activemq.ActiveMQSession -
> ID:tjock-xxl-46934-1345727966509-3:1:1 Transaction Rollback, txid:null
> 2012-08-23 15:19:48,669 DEBUG
> org.apache.activemq.broker.region.AbstractRegion - localhost removing
> consumer: ID:tjock-xxl-46934-1345727966509-3:1:1:12 for destination:
> queue://events
> 2012-08-23 15:19:48,670 DEBUG org.apache.camel.component.jms.JmsConsumer -
> Stopping consumer: Consumer[activemq://queue:events]
> 2012-08-23 15:19:48,670 DEBUG org.apache.camel.component.jms.JmsConsumer -
> Stopping consumer: Consumer[activemq://queue:events]
> 2012-08-23 15:19:48,670 INFO  org.apache.camel.impl.DefaultShutdownStrategy
> - Graceful shutdown of 1 routes completed in 5 seconds
>
>
> /tw
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/shutting-down-Camel-in-flight-messages-gone-tp5717930p5717944.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to