On Thu, Dec 16, 2010 at 9:09 PM, John <john.fans...@ateb.com> wrote:
>
> I'm now working off 2.6-SNAPSHOT.
>
> To get around the onException/aggregate.groupBy DSL warning AND put the
> onException at the start of the route, I moved the actual send to the web
> service to it's own route. Unfortunately, I don't seem to be able to trigger
> the onException handling while testing the route. The global error handler
> kicks in after the 5 retries it is configured for.
>
> Am I doing something wrong with my onException configuration in the route?
> The code is below.
>
> Thanks,
>
> -john
>
>    errorHandler(deadLetterChannel("direct:emailSupport")
>        .maximumRedeliveries(5)
>        .redeliveryDelay(1000)
>        .backOffMultiplier(2)
>        .retryAttemptedLogLevel(LoggingLevel.WARN));
>
>    from("direct.sendToWs")
>        .routeId("sendToWs")
>
> .onException(java.net.ConnectException.class).maximumRedeliveries(-1).redeliveryDelay(30000).end()
>        .to("http:host//some_ws");
>
> In my test I created an interceptor like:
>
>    Predicate p1 = header(Exchange.REDELIVERY_COUNTER).isLessThan(7);
>    Predicate p =
> PredicateBuilder.or(header(Exchange.REDELIVERY_COUNTER).isNull(), p1);
>
>    interceptSendToEndpoint("http*")
>        .skipSendToOriginalEndpoint()
>        .choice()
>            .when(p)
>                .process(new Processor()
>                {
>                    public void process(Exchange exchange) throws Exception
>                    {
>                        System.out.println("---------------- throw
> ConnectException");
>                        throw new java.net.ConnectException();
>                    }
>                })
>            .otherwise()
>                .log("--------------- sending it on")
>                .to(postingAcceptWsEndpoint);
>

Ah I spotted it now. When Camel performs a redelivery its at *the
point of original* so it happens in the intercepted route. So what
happens is that it will just retry invoking that process method on
Processor because it threw the exception. It does not start all over
again, which means that the logic in the choice / when is not executed
on redelivery.

You will have to put that logic *inside* the Processor because that
being invoked again on redelivery attempts.

See the following unit tests added
http://svn.apache.org/viewvc?rev=1050690&view=rev
http://svn.apache.org/viewvc?rev=1050691&view=rev


> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/route-scoped-onException-tp3300994p3308494.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
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to