ivankelly commented on a change in pull request #1861: Cpp client: add
getLastMessageId and hasMessageAvailable in consmer and reader
URL: https://github.com/apache/incubator-pulsar/pull/1861#discussion_r194100685
##########
File path: pulsar-client-cpp/lib/ClientConnection.cc
##########
@@ -928,6 +939,34 @@ void ClientConnection::handleIncomingCommand() {
break;
}
+ case BaseCommand::GET_LAST_MESSAGE_ID_RESPONSE: {
+ const CommandGetLastMessageIdResponse&
getLastMessageIdResponse =
+ incomingCmd_.getlastmessageidresponse();
+ LOG_DEBUG(cnxString_ << "Received getLastMessageIdResponse
from server. req_id: "
+ <<
getLastMessageIdResponse.request_id());
+
+ Lock lock(mutex_);
+ PendingGetLastMessageIdRequestsMap::iterator it =
+
pendingGetLastMessageIdRequests_.find(getLastMessageIdResponse.request_id());
+
+ if (it != pendingGetLastMessageIdRequests_.end()) {
+ Promise<Result, MessageId> getLastMessageIdPromise =
it->second;
+ pendingGetLastMessageIdRequests_.erase(it);
+ lock.unlock();
+
+ MessageIdData messageIdData =
getLastMessageIdResponse.last_message_id();
+ MessageId messageId =
MessageId(messageIdData.partition(), messageIdData.ledgerid(),
+
messageIdData.entryid(), messageIdData.batch_index());
+
+ getLastMessageIdPromise.setValue(messageId);
+ } else {
+ LOG_WARN(
Review comment:
I assume you don't need unlock here, since you can just wait for the lock to
go out of scope?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services