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_r194109234
##########
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()) {
Review comment:
what does empty() do? Can the callback become empty between here and where
callback is used?
----------------------------------------------------------------
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