[cleanup][broker] Remove redundant `messagesForC` check in multi-consumer dispatcher
### Motivation
In `PersistentDispatcherMultipleConsumers#sendMessagesToConsumers`, it
checks `messagesForC > 0` while `messagesForC` is always greater than 0.
### Modifications
Remove the `if (messagesForC > 0)` check. In addition, call
`entries.subList(start, end)` before handling the replace case to avoid
`subList` being called twice.
@@ -557,17 +557,17 @@ public class PersistentDispatcherMultipleConsumers extends AbstractDispatcherMul
serviceConfig.getDispatcherMaxRoundRobinBatchSize());
messagesForC = Math.max(messagesForC / avgBatchSizePerMsg, 1);
- if (messagesForC > 0) {
int end = Math.min(start + messagesForC, entries.size());
+ List<Entry> entriesForThisConsumer = entries.subList(start, end);
+
// remove positions first from replay list first : sendMessages recycles entries
if (readType == ReadType.Replay) {
- entries.subList(start, end).forEach(entry -> {
+ entriesForThisConsumer.forEach(entry -> {
redeliveryMessages.remove(entry.getLedgerId(), entry.getEntryId());
});
}
SendMessageInfo sendMessageInfo = SendMessageInfo.getThreadLocal();
- List<Entry> entriesForThisConsumer = entries.subList(start, end);
EntryBatchSizes batchSizes = EntryBatchSizes.get(entriesForThisConsumer.size());
EntryBatchIndexesAcks batchIndexesAcks = EntryBatchIndexesAcks.get(entriesForThisConsumer.size());
@@ -592,7 +592,6 @@ public class PersistentDispatcherMultipleConsumers extends AbstractDispatcherMul
totalMessagesSent += sendMessageInfo.getTotalMessages();
totalBytesSent += sendMessageInfo.getTotalBytes();
}
- }
// acquire message-dispatch permits for already delivered messages
long permits = dispatchThrottlingOnBatchMessageEnabled ? totalEntries : totalMessagesSent;
