Apache Camel-消息重新传递发生在一个异常块执行之前
有如下骆驼路线.
@Override
public void configure() throws Exception {
onException(java.lang.Exception.class).useOriginalMessage()
.beanRef("discoveryService", "updateConnection")
.redeliveryPolicyRef("redeliverMessagePolicy");
from(ENDPOINT_URI).to(queueName);
}
在 xml 中定义如下重新交付策略-
with Redelivery policy defined as following in xml-
<redeliveryPolicyProfile id="redeliverMessagePolicy"
retryAttemptedLogLevel="WARN" maximumRedeliveries="8"
redeliveryDelay="${redeliveryDelay}" />
但是,当抛出异常时,会在 OnException 块执行之前进行重新传递尝试(一些配置属性在 onException 块中更新.在 OneException 内的 DiscoveryService 中有一个调试点,在重新传递尝试完成后调用它).因此,当前消息会丢失而不会重新传递.不知道为什么会这样.使用 activemq-camel 版本 5.8.0谢谢
However when an exception is thrown the redelivery attempts are made before the OnException block is executed(Some configuration properties get updated in the onException block. Have a debug point in DiscoveryService inside Onexception, it gets called after the redelivery attempts are made). Thus the current message gets lost without being redelivered. Not sure why this happens. Using activemq-camel version 5.8.0 Thnks
推荐答案
是的,这是有意的,onException 块仅在交换用尽时执行(例如,在所有重新交付尝试都失败后).
Yes this is intended, the onException block is only executed when the exchange is exhausted (eg after all redelivery attempts have failed).
在文档中详细了解 Camel 中的错误处理是如何工作的
Read more about how error handling in Camel works in the docs
- http://camel.apache.org/error-handling-in-骆驼.html
如果你有 Camel in Action 这本书的副本,它有一整章专门介绍有关错误处理的所有内容(最完整的文档)
And if you have a copy of the Camel in Action book it has an entire chapter devoted to cover all about error handling (most complete documentation there is)
如果您想在每次重新交付之前执行一些自定义逻辑,请使用 onRedelivery
处理器:http://camel.apache.org/exception-clause.html
If you want to do some custom logic before each redelivery, then use the onRedelivery
processor: http://camel.apache.org/exception-clause.html
相关文章