You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by stalbot <st...@ahold.com> on 2017/06/12 21:54:40 UTC

Re: Nested doTry-doCatch blocks

I ran into this today.  I have a route with doTry/doCatch, where in the
doCatch there is a choice()when()otherwise() block.  The code never reaches
"point 2" for me, even when MyHttpException is not thrown.

.from()
     ...
     .doTry()
          ...
          .log(level.INFO, log, "Reaches point 1.")
     .endDoTry()
     .doCatch(MyHttpException.class)
          ...
          .choice()
               .when()
                    ...
               .otherwise()
                    ...
          .end()
          .stop()
     .end()
     .log(level.INFO, log, "Reaches point 2.")
.end();

In the documentation doTry/doCatch/doFinally is always at the end of the
route, so I can't tell how to end that block and have code after it (i.e.:
point 2).



--
View this message in context: http://camel.465427.n5.nabble.com/Nested-doTry-doCatch-blocks-tp5748561p5803329.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Nested doTry-doCatch blocks

Posted by Bart Horré <ba...@anova.be>.
Hi,

try to simplify your route by using direct endpoints.
The ChoiceProcessor tends to behave strangely when the route gets more
complex.

.from()
     ...
     .doTry()
          ...
          .log(level.INFO, log, "Reaches point 1.")
     .endDoTry()
     .doCatch(MyHttpException.class)
          ...
          .choice()
               .when()
                   .to("direct:a")
               .otherwise()
                    .to("direct:b")
          .end()
          .stop()
     .end()
     .log(level.INFO, log, "Reaches point 2.")
.end();

Bart Horré
Anova r&d bvba

On Mon, Jun 12, 2017 at 11:54 PM, stalbot <st...@ahold.com> wrote:

> I ran into this today.  I have a route with doTry/doCatch, where in the
> doCatch there is a choice()when()otherwise() block.  The code never reaches
> "point 2" for me, even when MyHttpException is not thrown.
>
> .from()
>      ...
>      .doTry()
>           ...
>           .log(level.INFO, log, "Reaches point 1.")
>      .endDoTry()
>      .doCatch(MyHttpException.class)
>           ...
>           .choice()
>                .when()
>                     ...
>                .otherwise()
>                     ...
>           .end()
>           .stop()
>      .end()
>      .log(level.INFO, log, "Reaches point 2.")
> .end();
>
> In the documentation doTry/doCatch/doFinally is always at the end of the
> route, so I can't tell how to end that block and have code after it (i.e.:
> point 2).
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Nested-doTry-doCatch-blocks-tp5748561p5803329.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>