Croway opened a new pull request, #30058:
URL: https://github.com/apache/camel/pull/30058

   ## Problem
   
   [CAMEL-26989](https://issues.apache.org/jira/browse/CAMEL-26989)
   
   With `ignoreDeclarationExceptions=true` on the component, 
`RabbitAdmin.declareQueue` logs a failed queue declaration and returns `null`. 
`SpringRabbitMQEndpoint.declareElements` kept that `null` as the queue name and 
built `new Binding(null, ...)`, which Spring AMQP rejects since 3.0.4:
   
   ```
   org.apache.camel.FailedToStartRouteException: Failed to start route: route1 
because: `destination` cannot be null
   Caused by: java.lang.IllegalArgumentException: `destination` cannot be null
   ```
   
   So the consumer did not start in the case the option is documented for 
("ignore exceptions such as mismatched properties when declaring"): a queue 
that already exists with other arguments, for example a quorum queue while the 
endpoint declares a classic one. The same happened while the broker was down. 
With a generated queue name (no `queues` option), the `null` would also have 
been set as the queue name of the listener container. The producer with 
`autoDeclareProducer=true` goes through the same method.
   
   ## Fix
   
   When `declareQueue` returns `null`, use 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 the listener container.
   
   ## Tests
   
   - `SpringRabbitMQIgnoreDeclarationExceptionsTest` (no broker):
     - `consumerStartsWhenTheDeclarationsFailAndAreIgnored`: the connection 
factory points at a port where nothing listens; with 
`ignoreDeclarationExceptions=true` the route starts.
     - `queueIsBoundByItsNameWhenItsDeclarationFailsAndIsIgnored` and 
`generatedQueueIsConsumedByItsNameWhenItsDeclarationFailsAndIsIgnored`: an 
`AmqpAdmin` whose `declareQueue` returns `null` (as `RabbitAdmin` does when it 
ignores the failure); the binding and the listener container get the queue 
name, given or generated.
   - `RabbitMQConsumerIgnoreDeclarationExceptionsIT` (test-infra RabbitMQ): the 
queue exists as a quorum queue, the consumer declares it as a classic one; the 
route starts and consumes a message sent to the exchange.
   
   All four fail on `main` without the change (`destination` cannot be null) 
and pass with it. The module's unit tests (24) and integration tests (36, 4 
skipped as on `main`) pass.
   
   No option, default or documentation changes; no upgrade-guide entry (the 
option did not work before).
   
   Related: CAMEL-26990 (the consumer declares only once, at start).
   
   _Claude Code on behalf of Croway_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to