shashank created CAMEL-24942:
--------------------------------

             Summary: camel-seda - multipleConsumers=true silently 
load-balances instead of broadcasting when the consumer URIs differ in any 
other option
                 Key: CAMEL-24942
                 URL: https://issues.apache.org/jira/browse/CAMEL-24942
             Project: Camel
          Issue Type: Bug
          Components: camel-seda
            Reporter: shashank


With {{multipleConsumers=true}} every consumer should get a copy of each 
message. The option doc says "When enabled, this option should be specified on 
every consumer endpoint". Pub/sub only works when all subscriber routes use 
exactly the same endpoint URI:
* The queue is shared by name: {{SedaComponent.getQueueKey()}} drops the query 
string.
* Each distinct URI is a separate {{SedaEndpoint}} with its own consumer set 
and multicast processor.
* A consumer thread multicasts a polled message only to the consumers of its 
own endpoint ({{SedaConsumer.sendToConsumers}} uses 
{{getEndpoint().getConsumers()}} / 
{{getEndpoint().getConsumerMulticastProcessor()}}).

As a result, subscribers on different endpoints compete for the messages.

Reproduced against 4.23.0-SNAPSHOT, 10 messages sent to {{seda:news}}:
{noformat}
A: seda:news?multipleConsumers=true                     B: 
seda:news?multipleConsumers=true                         -> A 10, B 10
A: seda:news?multipleConsumers=true                     B: 
seda:news?multipleConsumers=true&concurrentConsumers=2   -> A 2,  B 8
A: seda:news?multipleConsumers=true                     B: 
seda:news?multipleConsumers=true&pollTimeout=500         -> A 7,  B 3
{noformat}
There is no error or warning. Adding a harmless option such as 
{{concurrentConsumers}} to one subscriber is enough to lose the broadcast. 
CAMEL-6451 already rejects consumers that mix {{multipleConsumers=true}} and 
{{false}} on one queue, but not this case.

Proposed fix, one of:
# Multicast over the consumers of all endpoints that share the 
{{QueueReference}}. The reference already tracks its endpoints 
({{QueueReference.hasConsumers()}} iterates them).
# Fail at start-up, like the CAMEL-6451 check in 
{{SedaEndpoint.createConsumer}}, when a consumer with 
{{multipleConsumers=true}} is added to a queue that already has consumers on a 
different endpoint instance. Also document that all subscribers must use the 
identical URI.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to