Hello sarfarj,
this is the doTry() doCatch() solution I've found. I remark that the
approach suggested by Claus (which is basically using the Recipient List EIP
to choose the dead letter queue at runtime) is much more cleaner.

        @Override
        public void configure() throws Exception {
                
                from(INBOUND_QUEUE)
                        
                        .threads(routeExecutionThreadCount)
                
                        .doTry()
                                
                                .to(DEST_1, DEST_2)                     
                                
                        .doCatch(Exception.class)
                        
                                .process(new
CounterHeaderIncrementorProcessor(Constants.MY_REDELIVERIES_COUNTER_HEADER,
1))
                                
                                .choice()
                                
                                
.when(header(Constants.MY_REDELIVERIES_COUNTER_HEADER).isLessThanOrEqualTo(redeliveriesCount))
                                                // redeliver 
'redeliveriesCount' times
                                                .log(LoggingLevel.ERROR, 
exceptionMessage().toString())
                                                
                                                .to(INBOUND_QUEUE).stop()
                                                
                                        .otherwise()
                                        
                                                
.log(LoggingLevel.ERROR,"Message <${body}> sent to deadLetterQueue <"+
DEAD_LETTER_QUEUE + ">")
                                                
                                                .to(DEAD_LETTER_QUEUE).stop()
                                                
                                .end()
                                
                        .end()
                ;

        }

--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-2-9-1-DeadLetterChannel-infinite-loop-tp5714961p5715422.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to