Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add doTry around a Content Based Router not supported

...

Info
titleCamel error handling is disabled

When using doTry .. doCatch .. doFinally then the regular Camel Error Handler does not apply. That means any onException or the likes does not trigger. The reason is that doTry .. doCatch .. doFinally is in fact its own error handler and that it aims to mimic and work like how try/catch/finally works in Java.

doTry around a Content Based Router not supported

Code Block
languagejava
from("direct:dotry").setExchangePattern(ExchangePattern.InOut)
           .doTry()
              .to("https://localhost:8080/rest/order/123")
              .choice()
                  .when().simple("${header.CamelHttpResponseCode} == '200'")
                     .convertBodyTo(String.class)
         			 // DO SOMETHING
                .endChoice()
           .doCatch(Exception.class) // NOT SUPPORTED !!
              .log(">> Exception")
           .endDoTry();


The ChoiceDefinition class which is part of the DSL language of Apache Camel to implement the Content Based Router EIP Pattern doesn’t extends the OutputDefinition, which means that you cannot define the doCatch after the ChoiceDefinition as presented with the previous example. If you want to catch the exception inside of ChoiceDefinition, you can use error handler or use doTry…doCatch inside of when part.

About doCatch and its power over Java

...