Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.16.1
-
None
-
Unknown
Description
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)
else
{ channel.basicReject(deliveryTag, false); }}