You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by XiaoLi Ding <xl...@talend.com> on 2012/12/10 09:59:04 UTC

答复: how to work for redelivery of onException?

hi,
asynchronization working now.
i found the prolem here.
should use

 onException(java.io.IOException.class)

        .handled(true).maximumRedeliveries(3).redeliveryDelay(2000).asyncDelayedRedelivery()

because if no redeliveryDelay,default delay is 0.so no asynchronization.

Best regards
Xiaoli Ding
________________________________
发件人: XiaoLi Ding
发送时间: 2012年12月9日 23:47
到: users@camel.apache.org
主题: how to work for redelivery of onException?

hi,

i want to know how where happen asynchronization for "Asynchronous delayed redelivery" when i use Exception clause.my code as follows:
=============================================
        onException(java.io.IOException.class)

       .handled(true).maximumRedeliveries(3).asyncDelayedRedelivery().routeId("cOnException_1")
            .process(new org.apache.camel.Processor() {
                public void process(org.apache.camel.Exchange exchange) throws Exception {
                    long tid = Thread.currentThread().getId();
                    System.out.println("after break out thread id = " + tid);

                }

            }).id("cProcessor_1");
        from("timer:myTimer2?repeatCount=1").routeId("cTimer_2").process(new org.apache.camel.Processor() {
            public void process(org.apache.camel.Exchange exchange) throws Exception {
                long tid = Thread.currentThread().getId();
                System.out.println("Trying thread id = " + tid);
                Thread.sleep(1000);
                throw new java.io.IOException("This is specially generated  java.io.IOException exception");
            }

        }).id("cProcessor_3").process(new org.apache.camel.Processor() {
            public void process(org.apache.camel.Exchange exchange) throws Exception {

            }

        }).id("cProcessor_2");

===========================================
the result is :
Trying thread id = 11
Trying thread id = 11
Trying thread id = 11
Trying thread id = 11
after break out thread id = 11
why always same thread here?even before handle and after handle the exception?
where should happen asynchronization?

thanks for reply.

Best regards
Xiaoli Ding