codelipenghui commented on code in PR #21682:
URL: https://github.com/apache/pulsar/pull/21682#discussion_r1427435491


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java:
##########
@@ -665,15 +672,9 @@ protected synchronized boolean 
trySendMessagesToConsumers(ReadType readType, Lis
         long totalEntries = 0;
         int avgBatchSizePerMsg = remainingMessages > 0 ? 
Math.max(remainingMessages / entries.size(), 1) : 1;
 
-        int firstAvailableConsumerPermits, currentTotalAvailablePermits;
-        boolean dispatchMessage;
-        while (entriesToDispatch > 0) {
-            firstAvailableConsumerPermits = getFirstAvailableConsumerPermits();
-            currentTotalAvailablePermits = Math.max(totalAvailablePermits, 
firstAvailableConsumerPermits);
-            dispatchMessage = currentTotalAvailablePermits > 0 && 
firstAvailableConsumerPermits > 0;
-            if (!dispatchMessage) {
-                break;
-            }
+        // If the dispatcher is closed, firstAvailableConsumerPermits will be 
0, which skips dispatching the
+        // messages.
+        while (entriesToDispatch > 0 && getFirstAvailableConsumerPermits() > 
0) {

Review Comment:
   ```suggestion
           while (entriesToDispatch > 0 && getFirstAvailableConsumerPermits() > 
0 && isAtleastOneConsumerAvailable()) {
   ```



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