Apache Camel-消息重新传递发生在一个异常块执行之前
Apache Camel- Message Redelivery happens before onexception block executes
有以下骆驼路线。
@Override
public void configure() throws Exception {
onException(java.lang.Exception.class).useOriginalMessage()
.beanRef("discoveryService", "updateConnection")
.redeliveryPolicyRef("redeliverMessagePolicy");
from(ENDPOINT_URI).to(queueName);
}
重新投递政策定义如下 xml-
<redeliveryPolicyProfile id="redeliverMessagePolicy"
retryAttemptedLogLevel="WARN" maximumRedeliveries="8"
redeliveryDelay="${redeliveryDelay}" />
但是,当抛出异常时,会在执行 OnException 块之前进行重新传递尝试(一些配置属性会在 onException 块中更新。在 Onexception 内的 DiscoveryService 中有一个调试点,它会在重新传递尝试完成后被调用制成)。因此,当前消息会丢失而不会重新传递。不知道为什么会这样。
使用 activemq-camel 版本 5.8.0
谢谢
是的,这是有意的,onException 块仅在交换耗尽 时执行(例如,在所有重新交付尝试都失败后)。
在文档中详细了解 Camel 中的错误处理方式
如果你有一本 Camel in Action 书,它有一整章专门介绍所有关于错误处理的内容(有最完整的文档)
如果您想在每次重新交付之前执行一些自定义逻辑,请使用 onRedelivery
处理器:http://camel.apache.org/exception-clause.html
有以下骆驼路线。
@Override
public void configure() throws Exception {
onException(java.lang.Exception.class).useOriginalMessage()
.beanRef("discoveryService", "updateConnection")
.redeliveryPolicyRef("redeliverMessagePolicy");
from(ENDPOINT_URI).to(queueName);
}
重新投递政策定义如下 xml-
<redeliveryPolicyProfile id="redeliverMessagePolicy"
retryAttemptedLogLevel="WARN" maximumRedeliveries="8"
redeliveryDelay="${redeliveryDelay}" />
但是,当抛出异常时,会在执行 OnException 块之前进行重新传递尝试(一些配置属性会在 onException 块中更新。在 Onexception 内的 DiscoveryService 中有一个调试点,它会在重新传递尝试完成后被调用制成)。因此,当前消息会丢失而不会重新传递。不知道为什么会这样。 使用 activemq-camel 版本 5.8.0 谢谢
是的,这是有意的,onException 块仅在交换耗尽 时执行(例如,在所有重新交付尝试都失败后)。
在文档中详细了解 Camel 中的错误处理方式
如果你有一本 Camel in Action 书,它有一整章专门介绍所有关于错误处理的内容(有最完整的文档)
如果您想在每次重新交付之前执行一些自定义逻辑,请使用 onRedelivery
处理器:http://camel.apache.org/exception-clause.html