Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9505

RabbitMQConsumer don't use Camel ExceptionHandler BEFORE requeing message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.16.1
    • 2.15.6, 2.16.2, 2.17.0
    • camel-rabbitmq
    • 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)

      { channel.basicReject(deliveryTag, true); }

      else

      { channel.basicReject(deliveryTag, false); }

      }

      Attachments

        Activity

          People

            acosentino Andrea Cosentino
            arnaudchotard Arnaud CHOTARD
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: