You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by FingolfinTEK <fi...@gmail.com> on 2015/12/18 12:23:39 UTC

RedeliveryErrorHandler#determineIfRedeliveryIsEnabled ignores OnExceptionDefinition#redeliveryPolicy field

Hi guys,

I have encountered an issue and I wanted to confirm it here before opening a
ticket on JIRA. Here's what I did in my RouteBuilder superclass (actually a
Java 8 interface with default methods but it's all the same):

// Defined a global error handler
errorHandler(deadLetterChannel("{{message.deadLetterChannel.default.uri}}").useOriginalMessage()
        .maximumRedeliveries(0).allowRedeliveryWhileStopping(false));

// Defined an override for RabbitMQ exceptions that I want retired
onException(ShutdownSignalException.class, MalformedFrameException.class,
        ProtocolException.class,
PossibleAuthenticationFailureException.class)
        .log(LoggingLevel.ERROR, "Error encountered when processing
${exchange}")
        .redeliveryPolicy(defaultRedeliveryPolicy())
        .to("{{message.lastDitch.uri}}")
        .setRedeliveryPolicy(rabbitMqConnectivityRedeliveryPolicy());

// Defined a default redelivery policy method
RedeliveryPolicyDefinition defaultRedeliveryPolicy() {
    return new RedeliveryPolicy().allowRedeliveryWhileStopping(false)
       
.useExponentialBackOff().maximumRedeliveries(3).backOffMultiplier(3).redeliveryDelay(1000);
}

I have a Camel test for the superclass that basically just throws an
instance of each of those exceptions and verifies that the exchange has been
processed 4 times in total. However, the test failed with this exception:
Caused by: java.lang.IllegalStateException: Redelivery is not enabled on
DeadLetterChannel[TraceInterceptor[process[Processor@0x7c3fdb62]],
mock://dlc]. Make sure you have configured the error handler properly.

After a quick debugging, I found that the bug is two-fold: 
* first, the OnExceptionDefinition#getRedeliveryPolicy returns
redeliveryPolicyType field instead of redeliveryPolicy
* second, RedeliveryErrorHandler#determineIfRedeliveryIsEnabled only
inspects the value returned from OnExceptionDefinition#getRedeliveryPolicy,
thus only getting the value from OnExceptionDefinition#redeliveryPolicyType
field and never from OnExceptionDefinition#redeliveryPolicy

Should I report this to JIRA or is it somehow expected behavior (which it
really shouldn't be)?

Thank you in advance,
Milos Milivojevic



--
View this message in context: http://camel.465427.n5.nabble.com/RedeliveryErrorHandler-determineIfRedeliveryIsEnabled-ignores-OnExceptionDefinition-redeliveryPolicyd-tp5775246.html
Sent from the Camel - Users mailing list archive at Nabble.com.