Apache Camel-消息重新交付发生在onexception块执行之前 [英] 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
Thnks
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
- < a href = http://camel.apache.org/error-handling-in-camel.html rel = nofollow> http://camel.apache.org/error-handling-in-camel.html
- http://camel.apache.org/error-handling-in-camel.html
如果您有《骆驼在行动》一书的副本,则整章将专门介绍有关错误处理的所有内容(有最完整的文档)
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-消息重新交付发生在onexception块执行之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!