camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Exception handler defined in one route builder doesn't apply fo the other
Date Wed, 26 Aug 2009 08:27:12 GMT
On Wed, Aug 26, 2009 at 9:54 AM, Srivatsa Katta<> wrote:
> Hi,
> I have two route builders, one the actual route builder used for runtime
> with proper configurations and all. The other one is added dynamically to
> the context and is used only for testing.
> For example:
> My first route builder looks like this.
>  onException(Exception.class).handled(true).process(new
> ExceptionProcessor());
>  from("jetty:http://firstHost/").choice().when(
> header(Exchange.HTTP_PATH).regex("^/xyz/.*"))
>                .to("direct:secondHost")
>                .when( header(Exchange.HTTP_PATH).regex("^/abc/.*"))
>                .to("direct:thirdHost")
>                .otherwise().setOutHeader(Exchange.HTTP_RESPONSE_CODE,
> constant(HttpStatus.SC_NOT_FOUND));
>  from("direct:secondHost").to("http://secondHost/");
>  from("direct:thirdHost").to("http://thirdHost/");
> As you can notice this is what that might go in the application runtime, but
> to do my testing, for example to see if an exception handling is being done
> or not, I need a route with one of the component throwing an exception and
> see if its being handled by onException declaration.
> So I choose to get hold of the camelContext in my test and then added a new
> route builder which has few dummy routes which throws exception. But what I
> have noticed is every route builder goes in to a certain group and the
> exception handler defined in one route builder does not apply for the other
> one.
> Is there a better way to test these kind of things ?? Or is there a way
> where i can add route to the existing group dynamically?

This will be supported later to include routes to an existing route.
Currently when you add a route builder they are totally separate.

See this ticket:

For testing you could copy the original route and add the needed
simulation error stuff.

> Any help appreciated.
> Cheers!!
> Katta
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Apache Camel Committer

Open Source Integration:

View raw message