-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Reader.HasNext() in Go client #3764
Conversation
@@ -1039,8 +1040,7 @@ void ConsumerImpl::hasMessageAvailableAsync(HasMessageAvailableCallback callback | |||
return; | |||
} | |||
|
|||
BrokerGetLastMessageIdCallback callback1 = [this, lastDequed, callback](Result result, | |||
MessageId messageId) { | |||
getLastMessageIdAsync([this, lastDequed, callback](Result result, MessageId messageId) { | |||
if (result == ResultOk) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can you refactor it to
const auto ret = (result == ResultOk && messageId > lastDequed && messageId.entryId() != -1);
callback(result, ret);
or even not use ret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this would improve readability
|
||
client, err := NewClient(ClientOptions{ | ||
URL: "pulsar://localhost:6650", | ||
//Logger: func(level logutil.LoggerLevel, file string, line int, message string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to checkin with these comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.. :) removing these
LGTM |
run java8 tests |
* Fixed Reader.HasNext() in Go client * Fixed formatting * Removed commented code
Merged in 2.3.1 at |
Motivation
In Go client, the
Reader.HasNext()
is currently broken because it returns "true" when there are no more messages to read.The issue is in the C++
Consumer::hasMessageAvailable()
, combined with the use of message listener. ThelastDequedMessage
is being updated only after the listener is triggered, therefore an app checkinghasMessageAvailable()
from the listener thread will always be 1 message behind.Since Go client wrapper, uses the listener internally, it is affected by this problem and it looks like a race condition with the
lastDequedMessage
being updated in a background thread.