Grokbase Groups Camel users July 2012
FAQ
Hi

Seems like this is a basic feature, but I cant get it working as i expected.

I have this route defined using Java DSL...

from(endPointURI).delay(5000)
.routeId(routeId)

/.onException(Throwable.class).handled(true).process(*getInputfileExceptionHandler()*).end()/
.process(updateHeadersForInputfileProcess(tenantId))
.to("bean:taskCreator")

.wireTap("bean:inputFileRouteLifeCycle?method=startChangeSetProcessing(" +
routeId + ", ${header.task} )")
.to("bean:taskAppenderCreator");

When a message gets to this route, the first thing getting executed is the
code in the Processor that is returned by getInputfileExceptionHandler().
Then it starts executing the other steps, and when there is an exception in
the other steps the exception handler is not getting called at all.

What am I missing here?

Thanks
Srikanth

--
View this message in context: http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

  • Smadarapu at Jul 12, 2012 at 4:49 pm
    I think i figured it out, the "onException" set up is per RouteBuilder and
    not per Route, so I removed the onException setup from route to the route
    builder and it is working as i want it.

    What i still don't understand is why does the Route definition supports the
    "onException" setup, what is the purpose?

    Also the per route builder setup adds a limitation that I cannot have the
    definition of two routes (in the same RouteBuilder class) that need
    different handling of the same exception.

    Thanks
    Srikanth

    --
    View this message in context: http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5715962.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Willem Jiang at Jul 13, 2012 at 2:57 am
    You can use the try ... catch ... finally DSL[1] if you want to check
    the exception you want per route.
    The "onException" is a more generic way to handle the exception per
    RouteBuilder.

    [1]http://camel.apache.org/try-catch-finally.html

    On Fri Jul 13 00:09:02 2012, smadarapu wrote:
    I think i figured it out, the "onException" set up is per RouteBuilder and
    not per Route, so I removed the onException setup from route to the route
    builder and it is working as i want it.

    What i still don't understand is why does the Route definition supports the
    "onException" setup, what is the purpose?

    Also the per route builder setup adds a limitation that I cannot have the
    definition of two routes (in the same RouteBuilder class) that need
    different handling of the same exception.

    Thanks
    Srikanth

    --
    View this message in context: http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5715962.html
    Sent from the Camel - Users mailing list archive at Nabble.com.


    --
    Willem
    ----------------------------------
    FuseSource
    Web: http://www.fusesource.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.javaeye.com (Chinese)
    Twitter: willemjiang
    Weibo: willemjiang
  • Claus Ibsen at Jul 13, 2012 at 5:49 am

    On Thu, Jul 12, 2012 at 6:09 PM, smadarapu wrote:
    I think i figured it out, the "onException" set up is per RouteBuilder and
    not per Route, so I removed the onException setup from route to the route
    builder and it is working as i want it.

    What i still don't understand is why does the Route definition supports the
    "onException" setup, what is the purpose?

    Also the per route builder setup adds a limitation that I cannot have the
    definition of two routes (in the same RouteBuilder class) that need
    different handling of the same exception.
    A route can have a N+ route scoped onException's. That is possible.

    If you put onException outside (from) then its scoped for the current
    RouteBuilder class.

    Thanks
    Srikanth

    --
    View this message in context: http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5715962.html
    Sent from the Camel - Users mailing list archive at Nabble.com.


    --
    Claus Ibsen
    -----------------
    FuseSource
    Email: cibsen@fusesource.com
    Web: http://fusesource.com
    Twitter: davsclaus, fusenews
    Blog: http://davsclaus.com
    Author of Camel in Action: http://www.manning.com/ibsen
  • Smadarapu at Jul 14, 2012 at 6:06 am
    Can you please elaborate "A route can have a N+ route scoped onException's.
    That is possible."

    In my case when I had the onException on the route, whatever the code i put
    for onException got executed immediately after a message arrived to that
    route (without an actual exception), and not when that exception really
    happened.

    --
    View this message in context: http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5716018.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Christian Müller at Jul 14, 2012 at 9:28 am
    It's documented here [1].

    You can e.g. do:
    from("direct:start")

    .onException(MyTechnicalException.class).maximumRedeliveries(0).handled(true).end()

    .onException(MyFunctionalException.class).maximumRedeliveries(0).handled(true).to("bean:myOwnHandler").end()
    .choice()
    .when().xpath("//type = 'myType'").to("bean:myServiceBean")
    .end()
    .to("mock:result");


    [1] http://camel.apache.org/exception-clause.html

    Best,
    Christian
    On Fri, Jul 13, 2012 at 5:57 PM, smadarapu wrote:

    Can you please elaborate "A route can have a N+ route scoped onException's.
    That is possible."

    In my case when I had the onException on the route, whatever the code i put
    for onException got executed immediately after a message arrived to that
    route (without an actual exception), and not when that exception really
    happened.

    --
    View this message in context:
    http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5716018.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Smadarapu at Jul 16, 2012 at 7:05 pm
    Hi Christian,

    If you read my initial post, my question is what am I missing. I had what
    you suggested but its not working.
    Christian Mueller wrote
    It's documented here [1].

    You can e.g. do:
    from("direct:start")

    .onException(MyTechnicalException.class).maximumRedeliveries(0).handled(true).end()

    .onException(MyFunctionalException.class).maximumRedeliveries(0).handled(true).to("bean:myOwnHandler").end()
    .choice()
    .when().xpath("//type = 'myType'").to("bean:myServiceBean")
    .end()
    .to("mock:result");


    [1] http://camel.apache.org/exception-clause.html

    Best,
    Christian

    On Fri, Jul 13, 2012 at 5:57 PM, smadarapu
    <srikanth.madarapu@>wrote:
    Can you please elaborate "A route can have a N+ route scoped
    onException's.
    That is possible."

    In my case when I had the onException on the route, whatever the code i
    put
    for onException got executed immediately after a message arrived to that
    route (without an actual exception), and not when that exception really
    happened.

    --
    View this message in context:
    http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5716018.html
    Sent from the Camel - Users mailing list archive at Nabble.com.

    --
    View this message in context: http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5716089.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Christian Müller at Jul 17, 2012 at 7:54 pm
    Could you have a look at [1]? There are many tests which make sure it works.
    And if it doesn't work for you, could you please attach a test which
    indicate this. With a test it's much more easier for us to check what's
    going wrong - in your code or in Camel. And at the end, you will have a
    solution in a shorter time.

    [1]
    https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/

    Best,
    Christian
    On Mon, Jul 16, 2012 at 6:20 PM, smadarapu wrote:

    Hi Christian,

    If you read my initial post, my question is what am I missing. I had what
    you suggested but its not working.
    Christian Mueller wrote
    It's documented here [1].

    You can e.g. do:
    from("direct:start")
    .onException(MyTechnicalException.class).maximumRedeliveries(0).handled(true).end()
    .onException(MyFunctionalException.class).maximumRedeliveries(0).handled(true).to("bean:myOwnHandler").end()
    .choice()
    .when().xpath("//type = 'myType'").to("bean:myServiceBean")
    .end()
    .to("mock:result");


    [1] http://camel.apache.org/exception-clause.html

    Best,
    Christian

    On Fri, Jul 13, 2012 at 5:57 PM, smadarapu
    <srikanth.madarapu@>wrote:
    Can you please elaborate "A route can have a N+ route scoped
    onException's.
    That is possible."

    In my case when I had the onException on the route, whatever the code i
    put
    for onException got executed immediately after a message arrived to that
    route (without an actual exception), and not when that exception really
    happened.

    --
    View this message in context:
    http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5716018.html
    Sent from the Camel - Users mailing list archive at Nabble.com.

    --
    View this message in context:
    http://camel.465427.n5.nabble.com/Exception-handling-in-Camel-Routes-tp5715952p5716089.html
    Sent from the Camel - Users mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedJul 12, '12 at 4:48p
activeJul 17, '12 at 7:54p
posts8
users4
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase