CAMEL-24071: camel-spring-rabbitmq - Trim queue names and reject multi-queue polling#24741
Conversation
…i-queue polling Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
gnodet
left a comment
There was a problem hiding this comment.
Clean, focused hardening of the RabbitMQ queue-name handling — LGTM.
What the PR does
-
DefaultListenerContainerFactory: trims each queue name after splitting on comma, so"q1, q2"works correctly instead of passing" q2"with leading whitespace tosetQueueNames. -
SpringRabbitPollingConsumer:- Trims the single queue name before calling
template.receive(queue). - Adds fail-fast validation in
doInit()— rejects multi-queue configs (queues=q1,q2) becauseRabbitTemplate.receive()only accepts a single queue name. Without this guard, the raw comma-separated string would be passed as a queue name, failing silently or producing unexpected behavior.
- Trims the single queue name before calling
-
Tests: Two new tests verify both the trimming behavior and the multi-queue rejection with a clear error message.
Checklist
- Tests — two new tests cover both changes
- Commit convention — JIRA key in title
- No public API break — internal factory / consumer behavior
- No security concerns
- CI — pending (just submitted)
Static analysis
ast-grep (only tool available) flagged a pre-existing broad catch (Exception e) in SpringRabbitPollingConsumer.receive() — not introduced by this PR.
Reviewed with Claude on behalf of gnodet. This review was generated by an AI agent and may contain inaccuracies; please verify all suggestions before applying.
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 29 compile-only — current: 9 all testedMaveniverse Scalpel detected 38 affected modules (current approach: 9).
|
Summary
Claude Code on behalf of davsclaus
split(",")on thequeuesoption now trims each entry, consistent withdeclareElements(). Previouslyqueues=q1, q2would make the listener subscribe to" q2"(leading space) while declaring"q2"— causing a mismatch at runtime.doInit()with a clear error, sinceRabbitTemplate.receive()only accepts a single queue name. Also trims the queue name inreceive().Test plan
DefaultListenerContainerFactoryTest— verifies queue names are trimmed after splitting"myqueue, myotherqueue"SpringRabbitPollingConsumerTest— verifiesdoInit()throwsIllegalArgumentExceptionfor multi-queue config🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com