rhuan080 commented on code in PR #11279: URL: https://github.com/apache/camel/pull/11279#discussion_r1313160202
########## components/camel-seda/src/main/java/org/apache/camel/component/seda/SedaComponent.java: ########## @@ -189,10 +186,27 @@ public synchronized QueueReference getOrCreateQueue( log.debug("Created queue {} with size {}", key, size); // create and add a new reference queue - ref = new QueueReference(queue, size, multipleConsumers); + QueueReference ref = new QueueReference(queue, size, multipleConsumers); ref.addReference(endpoint); getQueues().put(key, ref); + return ref; + } + private QueueReference getExistingQueueRef(SedaEndpoint endpoint, Integer size, QueueReference ref, String key) { + // if the given size is not provided, we just use the existing queue as is + if (size != null && !size.equals(ref.getSize())) { + // there is already a queue, so make sure the size matches + throw new IllegalArgumentException( + "Cannot use existing queue " + key + " as the existing queue size " + + (ref.getSize() != null ? ref.getSize() : SedaConstants.QUEUE_SIZE) + + " does not match given queue size " + size); + } + // add the reference before returning queue + ref.addReference(endpoint); + + if (log.isDebugEnabled()) { + log.debug("Reusing existing queue {} with size {} and reference count {}", key, size, ref.getCount()); + } return ref; } Review Comment: Can the 'synchronized' keyword in the 'registerQueue' method also be eliminated? I believe you can utilize 'computeIfAbsent,' as suggested by @essobedo in the comment above. -- 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: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org