简体   繁体   English

Apache Camel-消息重新交付发生在onexception块执行之前

[英]Apache Camel- Message Redelivery happens before onexception block executes

Have the following camel route. 有以下骆驼路线。

@Override
public void configure() throws Exception {

onException(java.lang.Exception.class).useOriginalMessage()
.beanRef("discoveryService", "updateConnection")
.redeliveryPolicyRef("redeliverMessagePolicy");

from(ENDPOINT_URI).to(queueName);
}

with Redelivery policy defined as following in xml- 带有在XML-

<redeliveryPolicyProfile id="redeliverMessagePolicy"
    retryAttemptedLogLevel="WARN" maximumRedeliveries="8"
    redeliveryDelay="${redeliveryDelay}" />

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). 但是,当引发异常时,将在执行OnException块之前进行重新交付尝试(某些配置属性在onException块中进行了更新。在Onexception中的DiscoveryService中具有调试点,在进行重新交付尝试后将调用该调试点)。 Thus the current message gets lost without being redelivered. 因此,当前消息会丢失,而不会重新传递。 Not sure why this happens. 不知道为什么会这样。 Using activemq-camel version 5.8.0 Thnks 使用activemq-camel版本5.8.0 Thnks

Yes this is intended, the onException block is only executed when the exchange is exhausted (eg after all redelivery attempts have failed). 是的,这是有意的,onException块仅在交换用尽时才执行(例如,在所有重新交付尝试均失败之后)。

Read more about how error handling in Camel works in the docs 在文档中详细了解Camel中的错误处理方式

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) 而且,如果您有《骆驼在行动》一书的副本,则整章将专门讨论错误处理的全部内容(提供了最完整的文档)

If you want to do some custom logic before each redelivery, then use the onRedelivery processor: http://camel.apache.org/exception-clause.html 如果要在每次重新交付之前进行一些自定义逻辑,请使用onRedelivery处理器: http : onRedelivery

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM