Page Created :
CAMEL :
Try Catch Finally
Try Catch Finally has been created by Claus Ibsen (Apr 20, 2009). Content:Try ... Catch ... FinallyCamel supports the Java equivalent of try .. catch and finally directly in the DSL. In Camel we prefix the keywords with do to avoid having same keyword as Java. So we have:
Notice this document is based on how it works in Camel 2.0. In Camel 1.x this feature isn't as powerful and it uses a slight different keyword names. About doCatch and its power over JavaThe doCatch in Camel is empowered over its Java sister. First of all you can define multiple exceptions to catch in a single block. And secondly you can attach a onWhen predicate to signal if the catch should trigger or not at runtime. To simulate rehrowing an exception from a doCatch you should use the handled predicate. If its evaluated to false Camel will reattach the exception on the Exchange. And just like Java the order in which you have multiple doCatch blocks matter. Camel will iterate from the top going down and use the first doCatch that matches the exception and if the onWhen predicate matches as well (if any provided). This is the same behavior as the Exception Clause. Using try .. catch .. finally in Java DSL |
Unsubscribe or edit your notifications preferences