[
https://issues.apache.org/jira/browse/CAMEL-24071?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-24071:
--------------------------------
Fix Version/s: 4.22.0
> camel-spring-rabbitmq - Inconsistent handling of comma-separated queues
> option (listener container does not trim; polling consumer broken with
> multiple queues)
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24071
> URL: https://issues.apache.org/jira/browse/CAMEL-24071
> Project: Camel
> Issue Type: Bug
> Components: camel-spring-rabbitmq
> Affects Versions: 4.22.0
> Reporter: Federico Mariani
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.22.0
>
> Attachments: SpringRabbitMQQueueNamesTrimTest.java
>
>
> The {{queues}} option is documented as a comma-separated list of queue names.
> Two code paths handle it inconsistently:
> 1. {{SpringRabbitMQEndpoint.declareElements()}} trims each name after
> splitting on comma, but {{DefaultListenerContainerFactory}} does not:
> {code:java}
> listener.setQueueNames(endpoint.getQueues().split(","));
> {code}
> With {{queues=q1, q2}} (whitespace after the comma, easy to produce from
> YAML/properties based configuration) the component declares queue {{q2}}
> while the listener container subscribes to {{" q2"}} (leading space), so the
> consumer fails passive declaration at runtime or listens on the wrong queue.
> Attached unit test fails on current main:
> {noformat}
> array contents differ at index [1], expected: <myotherqueue> but was: <
> myotherqueue>
> {noformat}
> 2. {{SpringRabbitPollingConsumer}} passes the raw comma-separated string as a
> single queue name:
> {code:java}
> message = template.receive(jmsEndpoint.getQueues(), timeout);
> {code}
> With multiple queues configured, {{RabbitTemplate.receive()}} is invoked
> against a queue literally named {{q1,q2}}, which fails with a channel error
> on the broker. The polling consumer should either use the first queue or
> reject a multi-queue configuration in {{doInit()}} with a clear error message
> (it already rejects {{queues=null}} there).
> ----
> _This issue was found during an AI-assisted code review of
> camel-spring-rabbitmq: Claude Code on behalf of Federico Mariani (fmariani).
> A failing unit test reproducing the issue is attached._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)