Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Camel choice() and doTry() don't seem to work together

Tags:

apache-camel

When I define a route (snippet) like this:

.doTry()
    .choice()
        .when(header("s").isEqualTo(1))
            .log(LoggingLevel.WARN, "normal")
    .endChoice()
.doCatch(Exception.class)
    .log(LoggingLevel.WARN, "exception")
.endDoTry()

I am getting a Cannot resolve method doCatch(...) error in my IDE (IntelliJ).

Am I not allowed to put choice predicates within doTry()?

like image 374
Tony Ennis Avatar asked Oct 18 '25 10:10

Tony Ennis


1 Answers

Try this:

.doTry()
    .choice()
        .when(header("s").isEqualTo(1))
            .log(LoggingLevel.WARN, "normal")
    .endDoTry()
.doCatch(Exception.class)
    .log(LoggingLevel.WARN, "exception")
.end()

I was making the same error as you not so long ago; "endDoTry" sounds like "end the doTry block" but I think it should in fact be read as "end whatever the current block is and go back to the enclosing try definition".

The same applies to "endChoice".

like image 93
Laurent Chabot Avatar answered Oct 20 '25 19:10

Laurent Chabot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!