davsclaus opened a new pull request, #30733: URL: https://github.com/apache/camel/pull/30733
_Claude Code on behalf of davsclaus_ JIRA: https://issues.apache.org/jira/browse/CAMEL-27205 Two problems in camel-spring-rabbitmq: 1. The `maximumRetryAttempts` endpoint option said the number includes the first try. The value goes to `RetryInterceptorBuilder.maxRetries(...)`, which counts the retries after the first try (spring-rabbit 4.2.0 passes it to Spring Framework 7.1 `RetryPolicy.Builder.maxRetries`). So 5 means up to 6 tries. The behaviour stays; the description is fixed. 2. With `autoDeclare=true`, `deadLetterExchange` and `deadLetterQueue` but no `deadLetterRoutingKey`, the consumer failed to start with `'routingKey' must be non-null`, also for a fanout exchange that does not use the key. ## Changes - `maximumRetryAttempts`: the endpoint and component descriptions now say the same: it is the number of retries, the first try is not counted, so 5 means up to 6 tries. - The dead letter queue is bound with the key the consumer queue dead-letters with, so the two stay consistent: `deadLetterRoutingKey`, else the `x-dead-letter-routing-key` queue argument (`arg.queue.x-dead-letter-routing-key`). - Without such a key, a `fanout` or `headers` dead letter exchange is bound with an empty routing key. - Without such a key, a `direct` or `topic` dead letter exchange fails at start with a clear message that names `deadLetterRoutingKey`. The check runs before anything is declared. - The `deadLetterRoutingKey` description says when the option is required. - Regenerated the component JSON, the catalog copy, and the endpoint and component DSL. Why fail for `direct` and `topic` instead of binding with the consumer `routingKey`: without `x-dead-letter-routing-key`, RabbitMQ dead-letters a message with its original routing key. That key is often not the consumer `routingKey`: with the default exchange the publisher uses the queue name, while `routingKey` is empty; a queue can also be bound with other keys, or get messages through CC/BCC headers. A wrong guess would drop the dead letters without any error. These configurations failed at start before this change too, so nothing that worked breaks. ## Tests - `SpringRabbitMQConsumerDeclareTest` (mocked `AmqpAdmin`): 10 new tests. Fanout and headers without a key bind with `""`; all four types with `deadLetterRoutingKey` bind with it and set it on the consumer queue; the queue argument is used when the option is not set; direct and topic without a key fail with the message and declare nothing; a dead letter exchange without a dead letter queue needs no key. - New `RabbitMQConsumerDeadLetterIT` (Testcontainers RabbitMQ): a failed message reaches the dead letter queue of a fanout dead letter exchange without `deadLetterRoutingKey`. - Module unit tests: 43 run, 43 passed. - Module integration tests: 40 run, 36 passed, 4 skipped (existing skips), 0 failed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
