davsclaus commented on code in PR #27799:
URL: https://github.com/apache/camel/pull/27799#discussion_r4266930738


##########
components/camel-sjms/src/main/java/org/apache/camel/component/sjms/consumer/SimpleMessageListenerContainer.java:
##########
@@ -358,14 +365,31 @@ protected void initConsumers() throws Exception {
             if (consumers == null) {
                 LOG.debug("Initializing {} concurrent consumers as JMS 
listener on destination: {}", concurrentConsumers,
                         destinationName);
-                sessions = new HashSet<>(concurrentConsumers);
-                consumers = new HashSet<>(concurrentConsumers);
-                for (int i = 0; i < this.concurrentConsumers; i++) {
-                    Session session = createSession(connection, endpoint);
-                    MessageConsumer consumer = createMessageConsumer(session);
-                    configureConsumer(consumer, session);
-                    sessions.add(session);
-                    consumers.add(consumer);
+                Set<Session> newSessions = new HashSet<>(concurrentConsumers);
+                Set<MessageConsumer> newConsumers = new 
HashSet<>(concurrentConsumers);
+                sessions = newSessions;
+                consumers = newConsumers;

Review Comment:
   These two assignments before the loop are what let `recoverConnection` see 
an `onException` that arrives while the loop runs (it nulls the fields, and the 
check at line 215 then retries). That is not obvious from here. Suggest a short 
comment, for example:
   
   ```suggestion
                   // assigned before the loop, so that an onException during 
the creation (it sets the fields to null)
                   // is seen by recoverConnection, which then tries again
                   sessions = newSessions;
                   consumers = newConsumers;
   ```



-- 
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]

Reply via email to