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_r194108728
 
 

 ##########
 File path: pulsar-client-cpp/lib/ConsumerImpl.cc
 ##########
 @@ -919,4 +919,65 @@ void ConsumerImpl::seekAsync(const MessageId& msgId, 
ResultCallback callback) {
     callback(ResultNotConnected);
 }
 
+void ConsumerImpl::hasMessageAvailableAsync(HasMessageAvailableCallback 
callback) {
+    if (this->lastMessageIdAvailable()) {
+        callback(ResultOk, true);
+        return;
+    }
+
+    BrokerGetLastMessageIdCallback callback1 = [this, callback](Result result, 
MessageId messageId) {
+        if (this->lastMessageIdAvailable()) {
+            callback(ResultOk, true);
+        } else {
+            callback(ResultOk, false);
+        }
+    };
+
+    getLastMessageIdAsync(callback1);
+}
+
+void ConsumerImpl::brokerGetLastMessageIdListener(Result res, MessageId 
messageId,
+                                                  
BrokerGetLastMessageIdCallback callback) {
+    if (!callback.empty()) {
+        lastMessageInBroker_ = Optional<MessageId>::of(messageId);
 
 Review comment:
   Why is this inside the callback check? Surely the info is still useful even 
if the callback has gone 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

Reply via email to