Apache Camel - onWhen() predicate 无法检索EXCEPTION_CAUGHT,但它存在于处理器中

fcg9iug3  于 11个月前  发布在  Apache
关注(0)|答案(1)|浏览(110)

doCatch()之后,我无法访问onWhen(predicate)中的捕获异常,但我可以在doCatch()中的处理器中看到它。当我想在onWhen()中定义一个更细粒度的 predicate 时,这是不方便的。

doCatch(ProcessingException.class).onWhen(predicate) // <<< here I cannot see exception
    .process(MyProcessor.class) // <<< here I see exception
    ...

exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class)在 predicate 中返回null。我看到exchange.getAllProperties()不包含密钥。
有什么想法吗?是故意的吗?现在我不能决定进入捕捉处理器或不依赖于异常消息。

kyxcudwk

kyxcudwk1#

我一直在努力解决这个问题,直到我阅读了该方法的文档:
设置一个额外的 predicate ,该 predicate 在触发onException之前应为true。
用于细粒度控制是否应通过此异常类型拦截抛出的异常。
这可以解释为什么您能够在处理器中而不是在“onWhen”子句中看到异常细节。
希望能帮上忙。
问候。

相关问题