Arnaud CHOTARD created CAMEL-9505:
-------------------------------------
Summary: RabbitMQConsumer don't use Camel ExceptionHandler BEFORE
requeing message
Key: CAMEL-9505
URL: https://issues.apache.org/jira/browse/CAMEL-9505
Project: Camel
Issue Type: Bug
Components: camel-rabbitmq
Affects Versions: 2.16.1
Reporter: Arnaud CHOTARD
The use case is :
onException(NotHandledException.class)
.handled(false)
.log("Exception not handled");
onException(HandledException.class)
.handled(true)
.log("Exception handled");
from("rabbitmq://...&autoAck=false")
.setHeader(RabbitMQConstants.REQUEUE, constant(true))
.to(...);
If the route generate a NotHandledException, the message is requeue in
RabbitMQ, it works fine.
If the route generate a HandledException, the message is requeue in RabbitMQ
before the execution of Camel ExceptionHandler wich should handle the exception
and should not propagate it.
The message handled by Camel ExceptionHandler should not be requeue in RabbitMQ
since the exception is handled.
The related code is in :
org.apache.camel.component.rabbitmq.RabbitConsumer.handleDelivery
Maybe this line :
getExceptionHandler().handleException("Error processing exchange", exchange,
exchange.getException());
should be before :
if (deliveryTag != 0 && !consumer.endpoint.isAutoAck()) {
log.trace("Rejecting receipt [delivery_tag={}] with requeue={}",
deliveryTag, isRequeueHeaderSet);
if (isRequeueHeaderSet) {
channel.basicReject(deliveryTag, true);
} else {
channel.basicReject(deliveryTag, false);
}
}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)