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-消息重新传递发生在一个异常块执行之前
基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 从 python 访问 JVM 2022-01-01
