Raymond Cuenen created CAMEL-8486:
-------------------------------------
Summary: Producer should not bind exchange to queue
Key: CAMEL-8486
URL: https://issues.apache.org/jira/browse/CAMEL-8486
Project: Camel
Issue Type: Bug
Components: camel-rabbitmq
Affects Versions: 2.15.0
Reporter: Raymond Cuenen
Fix For: 2.15.1
The {{RabbitMQConsumer}} and {{RabbitMQProducer}} classes both use the
{{declareExchangeAndQueue(Channel)}} method of the {{RabbitMQEndpoint}} class,
where an exchange always is declared and when the {{getQueue}} method does not
return {{null}} (line 222) a queue is declared and bound to the exchange.
First the {{getQueue}} method cannot return {{null}}, since the underlying
parameter is initialized at line 75 and as far as I know cannot be set to
{{null}} by an URI specification.
The fact that both the consumer and producer _connect_ the same way is wrong I
think. A producer should always publish to a queue or an exchange, while a
consumer always consumes from a queue, which optionally can be bound to an
exchange.
I would suggest to make separate declare methods for consumers and producers.
For consumers:
* always declare exchange (because of component URI specification)
* always declare queue (specified name or _random_)
* bind queue to exchange
** basicConsume(<queue>, ...)
For producers:
* only declare exchange when no queue specified
** basicPublish(<exchange>, routingKey, ...)
* only declare queue when specified (ignore exchange in URI specification)
** basicPublish("", <queue>, ...)
Unless the {{declare=false}} property is specified ofcourse. Note that the
binding still needs to be performed for a consumer (even when the queue and the
exchange are not declared)
With this the processing of the camel exchange for a producer might have to be
changed also; the current implementation always publishes to the exchange, but
it has to publish to the queue (exchange="", routingKey=<queue>) in the case a
queue is specified.
Because the current implementation also creates a binding between a (random
named) queue and an exchange the RabbitMQ broker is left with unused bounded
queues every time the application is started, which results in a new random
queue being created. The created queues with their bindings are not deleted
after the application stops (might be a bug in the broker. I'm not sure).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)