Pierre Chesneau created CAMEL-13245:
---------------------------------------
Summary: RabbitMq producer not always honoring
EXCHANGE_OVERRIDE_NAME header
Key: CAMEL-13245
URL: https://issues.apache.org/jira/browse/CAMEL-13245
Project: Camel
Issue Type: Bug
Components: camel-rabbitmq
Affects Versions: 2.23.1
Reporter: Pierre Chesneau
The RabbitMqProducer and RabbitMqPublisher do not honor the
EXCHANGE_OVERRIDE_NAME header when used for a routing Key not starting with
{color:#333333}RabbitMQConstants.RABBITMQ_DIRECT_REPLY_ROUTING_KEY.{color}
{color:#660e7a}{color:#333333}For example :{color} {color}
{color:#333333}{{from("stream:in?promptMessage=Enter message payload:
").}}{{setHeader(RabbitMQConstants.EXCHANGE_OVERRIDE_NAME,constant("")).setHeader(RabbitMQConstants.ROUTING_KEY,constant("test"))}}
{{.to("rabbitmq:uselessExchange");}}{color}
{color:#333333}will publish the message with the routing key "test" on the
"uselessExchange" exchange instead of the expected "" (default exchange).{color}
{color:#333333}This seems to come from a conflict between : {color}
*
{color:#333333}_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.
{color}
*
{color:#333333}_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){color}
{color:#333333}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{color}
{color:#333333}which overrides the exchange_override_name with the default
exchange.{color}
{color:#333333}I would gladly create a PR or a patch with a correction, but I'm
not sure of the intended behavior ? {color}
{color:#333333}Should we: {color}
* {color:#333333} do not extract the EXCHANGE_OVERRIDE_NAME in the
_org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOnly_{color}
* {color:#333333}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_{color}
{color:#333333}In my Opinion the best solution would be to remove the
extraction of the header in {color}
{color:#333333}_org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOnly
(and org.apache.camel.component.rabbitmq.RabbitMQProducer#processInOut)_
{color}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)