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

RabbitMq producer not always honoring EXCHANGE_OVERRIDE_NAME header

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.23.1
    • 3.0.0.RC2, 3.0.0
    • camel-rabbitmq
    • None
    • Unknown

    Description

      The RabbitMqProducer and RabbitMqPublisher do not honor the EXCHANGE_OVERRIDE_NAME header when used for a routing Key not starting with

      RabbitMQConstants.RABBITMQ_DIRECT_REPLY_ROUTING_KEY.

      For example :

      from("stream:in?promptMessage=Enter message payload: ").setHeader(RabbitMQConstants.EXCHANGE_OVERRIDE_NAME,constant("")).setHeader(RabbitMQConstants.ROUTING_KEY,constant("test"))
      .to("rabbitmq:uselessExchange");

      will publish the message with the routing key "test" on the "uselessExchange" exchange instead of the expected "" (default exchange).

      This seems to come from a conflict between :

      • org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOnly which extract and remove the exchange override name, then pass it to org.apache.camel.component.rabbitmq.RabbitMQProducer#basicPublish where it is not used.
      • _org.apache.camel.component.rabbitmq.RabbitMQMessagePublisher#publishToRabbit_MQ (that is called by the previous function through the ChannelCallback) where the Exchange override name is once again removed (though it is null now, since it has been removed previously)

      Note that when the routing key starts with RABBITMQ_DIRECT_REPLY_ROUTING_KEY the behavior is almost correct thanks to org.apache.camel.component.rabbitmq.RabbitMQMessagePublisher#resolveMessageFrom

      which overrides the exchange_override_name with the default exchange.

      I would gladly create a PR or a patch with a correction, but I'm not sure of the intended behavior ?

      Should we: 

      • do not extract the EXCHANGE_OVERRIDE_NAME in the org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOnly
      • Extract it but make sure it goes all the way down to the org.apache.camel.component.rabbitmq.RabbitMQMessagePublisher#RabbitMQMessagePublisher constructor where it could be saved and reused later by the org.apache.camel.component.rabbitmq.RabbitMQMessagePublisher#publishToRabbitMQ

      In my Opinion the best solution would be to remove the extraction of the header in

      org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOnly (and org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOut)

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            pchesneau Pierre Chesneau
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: