[ 
https://issues.apache.org/jira/browse/CAMEL-26989?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Work on CAMEL-26989 started by Federico Mariani.
------------------------------------------------
> camel-spring-rabbitmq - with ignoreDeclarationExceptions=true, a failed queue 
> declaration stops the consumer from starting with "`destination` cannot be 
> null"
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26989
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26989
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-spring-rabbitmq
>    Affects Versions: 4.18.5, 4.22.2, 4.23.0
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Major
>
> The component option {{ignoreDeclarationExceptions}} ("Switch on ignore 
> exceptions such as mismatched properties when declaring") is set on the 
> {{RabbitAdmin}} the component creates for a consumer 
> ({{DefaultListenerContainerFactory}}) and for a producer with 
> {{autoDeclareProducer=true}} ({{SpringRabbitMQProducer}}). When the 
> declaration that fails is the queue's, {{RabbitAdmin.declareQueue}} logs 
> "Failed to declare queue: ..., continuing..." and returns {{null}}. 
> {{SpringRabbitMQEndpoint.declareElements}} keeps that {{null}} as the queue 
> name and binds it:
> {code:java}
> qn = admin.declareQueue(rabbitQueue);   // null when the exception is ignored
> ...
> Binding binding = new Binding(qn, Binding.DestinationType.QUEUE, 
> exchangeName, routingKey, getBindingArgs());
> {code}
> {{Binding}} rejects a null destination since Spring AMQP 3.0.4, so the route 
> does not start:
> {noformat}
> WARN  RabbitAdmin - Failed to declare queue: Queue [name=orders, ...], 
> continuing... com.rabbitmq.client.ShutdownSignalException: channel error; 
> protocol method: #method<channel.close>(reply-code=406, 
> reply-text=PRECONDITION_FAILED - inequivalent arg 'x-queue-type' for queue 
> 'orders' in vhost '/': received 'classic' but current is 'quorum', ...)
> org.apache.camel.FailedToStartRouteException: Failed to start route: route1 
> because: `destination` cannot be null
> Caused by: java.lang.IllegalArgumentException: `destination` cannot be null
> {noformat}
> So the option fails in the case it is documented for: a queue that already 
> exists with other arguments. The same happens when the broker is not 
> reachable at startup. With a generated queue name (no {{queues}} option) the 
> {{null}} would also be set as the queue name of the listener container.
> *Steps to reproduce*
> # Declare the queue {{orders}} as a quorum queue on the broker.
> # Set {{ignoreDeclarationExceptions=true}} on the spring-rabbitmq component.
> # Start a route 
> {{from("spring-rabbitmq:orders?queues=orders&routingKey=new")}}: the consumer 
> declares {{orders}} as a classic queue, which the broker refuses with 
> PRECONDITION_FAILED.
> *Expected*: the failed queue declaration is logged and ignored, the binding 
> is declared with the queue name, the route starts and consumes from the 
> existing queue.
> *Actual*: {{FailedToStartRouteException}} caused by 
> {{IllegalArgumentException: `destination` cannot be null}}.
> Reproduced on 4.23.0 and 4.24.0-SNAPSHOT. The code is the same in 4.18.x and 
> 4.22.x, whose Spring AMQP versions (3.2.x, 4.1.x) have the same check in 
> {{Binding}}.
> *Fix direction*: when {{declareQueue}} returns {{null}}, keep the name of the 
> {{Queue}} that was declared ({{rabbitQueue.getName()}}: the name given in 
> {{queues}}, or the one generated on the client) for the binding and for the 
> listener container.
> Related: CAMEL-16003 (the rework using Spring AMQP, where the option comes 
> from).
> _Claude Code on behalf of Croway_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to