You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anand sridhar <an...@gmail.com> on 2012/02/14 21:35:20 UTC

Defining Exception Handlers in separate RouteBuilder classes.

Hello,
I am trying to build a application with several camel routes which re use
many common routes internally.
Hence, I am trying to segregate the routes in several different Route
Builder classes and then connecting the routes where needed.

For eg,  all routes pertaining to sending emails go into a
EmailRouteBuilder class and all routes dealing with a particular JMS Queue
go into MyQueueRouteBuilder class.
I suppose this should be alright since Camel doesnt not distinguish between
classes and only looks for routes defininition.

In addition, I am also grouping several exception handling routes into a
separate ExceptionHandlingRouteBuilder.

I am also connecting all the different classes together by defining the
camel context in Spring like so -

<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring
">
        <propertyPlaceholder id="properties"
location="classpath:${env}/autoimport.properties"/>
        <!-- Common Routes -->
        <routeBuilder ref="emailRouteBuilder" />
        <routeBuilder ref="myQueueRouteBuilder" />
      <routeBuilder ref="httpRouteBuilder" />
        <routeBuilder ref="exceptionsRouteBuilder" />
        <routeBuilder ref="customer1RouteBuilder" />
        <routeBuilder ref="customer2RouteBuilder" />

    </camelContext>


However, it looks like there is a problem with the exceptions being defined
in another class, or for that matter, defined separately out of the main
route definition.

I verified this in the logs by looking for the routes being booted ( by
routeId ) and also checking when an exception is thrown.

Additionally, to further confirm, I took the http Connect Exception
handling route and put that directly in the httpRouteBuilder and lo..! ,
the exception handling now kicks in just fine for this exception..

Am I missing something here to get all exceptions to work while being
nicely defined in its own class. ?

Thanks,
Anand

Re: Defining Exception Handlers in separate RouteBuilder classes.

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this question on stackoverflow
http://stackoverflow.com/questions/9283861/camel-exception-handling-doesnt-work-if-exception-clause-is-defined-in-a-separat

On Tue, Feb 14, 2012 at 9:35 PM, anand sridhar <an...@gmail.com> wrote:
> Hello,
> I am trying to build a application with several camel routes which re use
> many common routes internally.
> Hence, I am trying to segregate the routes in several different Route
> Builder classes and then connecting the routes where needed.
>
> For eg,  all routes pertaining to sending emails go into a
> EmailRouteBuilder class and all routes dealing with a particular JMS Queue
> go into MyQueueRouteBuilder class.
> I suppose this should be alright since Camel doesnt not distinguish between
> classes and only looks for routes defininition.
>
> In addition, I am also grouping several exception handling routes into a
> separate ExceptionHandlingRouteBuilder.
>
> I am also connecting all the different classes together by defining the
> camel context in Spring like so -
>
> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring
> ">
>        <propertyPlaceholder id="properties"
> location="classpath:${env}/autoimport.properties"/>
>        <!-- Common Routes -->
>        <routeBuilder ref="emailRouteBuilder" />
>        <routeBuilder ref="myQueueRouteBuilder" />
>      <routeBuilder ref="httpRouteBuilder" />
>        <routeBuilder ref="exceptionsRouteBuilder" />
>        <routeBuilder ref="customer1RouteBuilder" />
>        <routeBuilder ref="customer2RouteBuilder" />
>
>    </camelContext>
>
>
> However, it looks like there is a problem with the exceptions being defined
> in another class, or for that matter, defined separately out of the main
> route definition.
>
> I verified this in the logs by looking for the routes being booted ( by
> routeId ) and also checking when an exception is thrown.
>
> Additionally, to further confirm, I took the http Connect Exception
> handling route and put that directly in the httpRouteBuilder and lo..! ,
> the exception handling now kicks in just fine for this exception..
>
> Am I missing something here to get all exceptions to work while being
> nicely defined in its own class. ?
>
> Thanks,
> Anand



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/