BewareMyPower commented on code in PR #17739:
URL: https://github.com/apache/pulsar/pull/17739#discussion_r976521719
##########
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:
We should add thread safe `remove` and `deleteAckedMessage` methods that
accept `MessageIdList` to make these calls thread safe. You can see both
`UnAckedMessageTrackerEnabled::remove` and
`BatchAcknowledgementTracker::deleteAckedMessage` are thread safe so the
`acknowledgeAsync` method for a single message won't lead to a race condition
for each component (`unAckedMessageTrackerPtr_` and `unAckedMessageTrackerPtr_`)
--
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]