Apache Camel- Message Redelivery happens before onexception block executes(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
这篇关于Apache Camel-消息重新传递发生在一个异常块执行之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Apache Camel-消息重新传递发生在一个异常块执行之前


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01