简体   繁体   中英

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-

<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). Thus the current message gets lost without being redelivered. Not sure why this happens. Using activemq-camel version 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).

Read more about how error handling in Camel works in the docs

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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