codelipenghui commented on code in PR #16812:
URL: https://github.com/apache/pulsar/pull/16812#discussion_r930842492
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/DelayedDeliveryTest.java:
##########
@@ -278,7 +278,6 @@ public void
testDelayedDeliveryWithMultipleConcurrentReadEntries()
for (int i = 0; i < N; i++) {
msg = consumer.receive(10, TimeUnit.SECONDS);
receivedMsgs.add(msg.getValue());
- consumer.acknowledge(msg);
Review Comment:
Why need to remove this line?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java:
##########
@@ -528,26 +533,38 @@ public synchronized void readEntriesComplete(List<Entry>
entries, Object ctx) {
log.debug("[{}] Distributing {} messages to {} consumers", name,
entries.size(), consumerList.size());
}
+ // dispatch messages to a separate thread, but still in order for this
subscription
+ // sendMessagesToConsumers is responsible for running broker-side
filters
+ // that may be quite expensive
if (serviceConfig.isDispatcherDispatchMessagesInSubscriptionThread()) {
- // dispatch messages to a separate thread, but still in order for
this subscription
- // sendMessagesToConsumers is responsible for running broker-side
filters
- // that may be quite expensive
+ // setting sendInProgress here, because sendMessagesToConsumers
will be executed
+ // in a separate thread, and we want to prevent more reads
+ sendInProgress = true;
dispatchMessagesThread.execute(safeRun(() ->
sendMessagesToConsumers(readType, entries)));
} else {
sendMessagesToConsumers(readType, entries);
}
}
protected synchronized void sendMessagesToConsumers(ReadType readType,
List<Entry> entries) {
+ sendInProgress = true;
+ try {
+ trySendMessagesToConsumers(readType, entries);
+ } finally {
+ sendInProgress = false;
+ }
+ readMoreEntries();
+ }
+ protected synchronized void trySendMessagesToConsumers(ReadType readType,
List<Entry> entries) {
Review Comment:
The PersistentStickyKeyDispatcherMultipleConsumers should also override this
method.
--
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]