BewareMyPower commented on code in PR #17739:
URL: https://github.com/apache/pulsar/pull/17739#discussion_r976530744
##########
pulsar-client-cpp/lib/MultiTopicsConsumerImpl.cc:
##########
@@ -572,6 +572,46 @@ void MultiTopicsConsumerImpl::acknowledgeAsync(const
MessageId& msgId, ResultCal
}
}
+void MultiTopicsConsumerImpl::acknowledgeAsync(const MessageIdList&
messageIdList, ResultCallback callback) {
+ if (state_ != Ready) {
+ callback(ResultAlreadyClosed);
+ return;
+ }
+
+ std::map<std::string, MessageIdList> topicToMessageId;
+ for (const MessageId& messageId : messageIdList) {
+ auto topicName = messageId.getTopicName();
+ if (topicToMessageId.count(topicName) == 0) {
+ topicToMessageId.emplace(topicName, std::vector<MessageId>());
+ }
+ topicToMessageId[topicName].emplace_back(messageId);
+ }
+
+ std::shared_ptr<std::atomic<int>> needCallBack =
+ std::make_shared<std::atomic<int>>(topicToMessageId.size());
+ auto cb = [callback, needCallBack](Result result) {
+ if (result != ResultOk) {
+ callback(result);
+ }
Review Comment:
If the results are all not `ResultOk` in N message IDs, then the callback
will be called for N times. We should guarantee the callback is called only
once.
--
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]