You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rafaljaw <ra...@gmail.com> on 2013/05/14 22:53:03 UTC
Why dead letter channel doesn't work after adding Processor to
onException?
Hi all,
I have simple route that takes messages from [Input] and forwards them to
[Output], or to [Failed] (dead letter queue) if something bad happens:
errorHandler(deadLetterChannel("jms:queue:Failed")
.maximumRedeliveries(1)
.redeliveryDelay(0));
onException(Throwable.class)
.maximumRedeliveries(0)
.handled(true);
from("jms:queue:Input")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("Processing msg " +
exchange.getIn().getBody());
throw new RuntimeException("Something bad happens here...");
}
})
.to("jms:queue:Output");
Everything works as expected - all messages are placed on [Failed] queue
since we are throwing RuntimeException in processor. But it doesn't work
after adding processor to onException:
errorHandler(deadLetterChannel("jms:queue:Failed")
.maximumRedeliveries(1)
.redeliveryDelay(0));
onException(Throwable.class)
.maximumRedeliveries(0)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("Exception is intercepted...");
}
})
.handled(true);
from("jms:queue:Input")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("Processing msg " +
exchange.getIn().getBody());
throw new RuntimeException("Something bad happens here...");
}
})
.to("jms:queue:Output");
I'm loosing all messages now - why? Why adding processor to onException is
so special?
I'm using Camel 2.6 and ActiveMQ 5.8.0.
Regards,
Rafal
--
View this message in context: http://camel.465427.n5.nabble.com/Why-dead-letter-channel-doesn-t-work-after-adding-Processor-to-onException-tp5732535.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Why dead letter channel doesn't work after adding Processor to onException?
Posted by Franz Paul Forsthofer <em...@googlemail.com>.
Hi Rafal,
please try handled(false);
My understanding is that then the error handler is called. However, I do
not understand why the first example with handled(true) works.
Regards Franz Forsthofer
--------------------------
SAP AG
e-mail: franz.forsthofer@sap.com
On Tue, May 14, 2013 at 10:53 PM, rafaljaw <ra...@gmail.com> wrote:
> Hi all,
>
> I have simple route that takes messages from [Input] and forwards them to
> [Output], or to [Failed] (dead letter queue) if something bad happens:
>
> errorHandler(deadLetterChannel("jms:queue:Failed")
> .maximumRedeliveries(1)
> .redeliveryDelay(0));
>
> onException(Throwable.class)
> .maximumRedeliveries(0)
> .handled(true);
>
> from("jms:queue:Input")
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> System.out.println("Processing msg " +
> exchange.getIn().getBody());
> throw new RuntimeException("Something bad happens
> here...");
> }
> })
> .to("jms:queue:Output");
>
> Everything works as expected - all messages are placed on [Failed] queue
> since we are throwing RuntimeException in processor. But it doesn't work
> after adding processor to onException:
>
>
> errorHandler(deadLetterChannel("jms:queue:Failed")
> .maximumRedeliveries(1)
> .redeliveryDelay(0));
>
> onException(Throwable.class)
> .maximumRedeliveries(0)
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> System.out.println("Exception is intercepted...");
> }
> })
> .handled(true);
>
> from("jms:queue:Input")
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> System.out.println("Processing msg " +
> exchange.getIn().getBody());
> throw new RuntimeException("Something bad happens
> here...");
> }
> })
> .to("jms:queue:Output");
>
> I'm loosing all messages now - why? Why adding processor to onException is
> so special?
> I'm using Camel 2.6 and ActiveMQ 5.8.0.
>
> Regards,
> Rafal
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Why-dead-letter-channel-doesn-t-work-after-adding-Processor-to-onException-tp5732535.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>