出现异常时,如何停止骆驼路线。我的动态路由消耗了jms并发送到反应性端点。
12aAB
路由生成器类如下:
camelContext.addRoutes(New GenerateRoute());
答案 0 :(得分:2)
尝试一下
from("jms:queue:myQueue")
.routeId("myRoute")
.doTry()
.toF("reactive-streams:myStream")
.doCatch(Exception.class)
.process(exchange -> exchange.getFromEndpoint().stop())
.end();
答案 1 :(得分:1)
您可以使用handled
和continued
。在onException
子句中。 “继续使您可以处理并继续在原始路由中进行处理,就好像未发生异常一样。”如果continued
为假,则路由不会返回到原始路由。
DSL:
<onException>
<exception>java.lang.IllegalArgumentException</exception>
<continued><constant>false</constant></continued>
</onException>
Java:
onException(IllegalArgumentException.class).continued(fasle);
引用:https://camel.apache.org/manual/latest/exception-clause.html#