You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/03 15:05:48 UTC

[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #8996: Ack response implementation

BewareMyPower commented on code in PR #8996:
URL: https://github.com/apache/pulsar/pull/8996#discussion_r1013031045


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -118,175 +122,302 @@ public boolean isDuplicate(MessageId messageId) {
     }
 
     @Override
-    public CompletableFuture<Void> addListAcknowledgment(List<MessageIdImpl> messageIds,
+    public CompletableFuture<Void> addListAcknowledgment(List<MessageId> messageIds,
                                                          AckType ackType, Map<String, Long> properties) {
-        if (ackType == AckType.Cumulative) {
-            messageIds.forEach(messageId -> doCumulativeAck(messageId, null));
-            return CompletableFuture.completedFuture(null);
+        if (AckType.Cumulative.equals(ackType)) {
+            if (ackResponseEnabled) {
+                Set<CompletableFuture<Void>> completableFutureSet = new HashSet<>();
+                messageIds.forEach(messageId ->
+                        completableFutureSet.add(addAcknowledgment((MessageIdImpl) messageId, ackType, properties)));
+                return FutureUtil.waitForAll(new ArrayList<>(completableFutureSet));
+            } else {
+                messageIds.forEach(messageId -> addAcknowledgment((MessageIdImpl) messageId, ackType, properties));
+                return CompletableFuture.completedFuture(null);
+            }
+        } else {
+            if (ackResponseEnabled) {
+                try {
+                    // when flush the ack, we should bind the this ack in the currentFuture, during this time we can't
+                    // change currentFuture. but we can lock by the read lock, because the currentFuture is not change
+                    // any ack operation is allowed.
+                    this.lock.readLock().lock();

Review Comment:
   It's fixed by #10742



-- 
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-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org