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/09/22 03:42:28 UTC

[GitHub] [pulsar] shibd commented on a diff in pull request #17739: [improve][cpp] Support acknowledging a list of messages

shibd commented on code in PR #17739:
URL: https://github.com/apache/pulsar/pull/17739#discussion_r977163674


##########
pulsar-client-cpp/lib/ConsumerImpl.cc:
##########
@@ -925,9 +926,21 @@ void ConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callb
     doAcknowledgeIndividual(msgId, cb);
 }
 
+void ConsumerImpl::acknowledgeAsync(const MessageIdList& messageIdList, ResultCallback callback) {
+    ResultCallback cb = std::bind(&ConsumerImpl::statsAckCallback, shared_from_this(), std::placeholders::_1,
+                                  callback, proto::CommandAck_AckType_Individual, messageIdList.size());
+    // Currently not supported batch message id individual index ack.
+    this->ackGroupingTrackerPtr_->addAcknowledgeList(messageIdList);
+    for (const auto& messageId : messageIdList) {
+        this->unAckedMessageTrackerPtr_->remove(messageId);
+        this->batchAcknowledgementTracker_.deleteAckedMessage(messageId, proto::CommandAck::Individual);
+    }

Review Comment:
   Yes, It is better to provide an accept `MessageIdList` method. I will provide it. 
   
   But I want to know what is the race condition for the actual scenario. For `UnAckedMessageTracker`, Will there be the following scenario?
   
   have a `MessageIdList`: {1, 2, 3, 4}
   
   on acknowledge thread:
   
   ``` c++
   for MessageIdList{
        this->unAckedMessageTrackerPtr_->remove(msgId);
   }
   ```
   
   and another thread to call: `this->unAckedMessageTrackerPtr_->add(msgId);`  
   
   



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