You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Srivatsa Katta <va...@gmail.com> on 2009/08/26 09:54:11 UTC

Exception handler defined in one route builder doesn't apply fo the other

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?

Any help appreciated.

Cheers!!
Katta


-- 
View this message in context: http://www.nabble.com/Exception-handler-defined-in-one-route-builder-doesn%27t-apply-fo-the-other-tp25148245p25148245.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Exception handler defined in one route builder doesn't apply fo the other

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Aug 26, 2009 at 9:54 AM, Srivatsa Katta<va...@gmail.com> 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:
https://issues.apache.org/activemq/browse/CAMEL-1919


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: http://www.nabble.com/Exception-handler-defined-in-one-route-builder-doesn%27t-apply-fo-the-other-tp25148245p25148245.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus