Skip to content
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

Pulsar reader doesn't return correct last message with startMessageIdInclusive() #9330

Closed
maimom1924 opened this issue Jan 26, 2021 · 9 comments
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@maimom1924
Copy link

maimom1924 commented Jan 26, 2021

I want to read last message from topic "A" by using Pulsar Reader as shown in below code:

Reader<byte[]> reader= pulsarClient.newReader()
                    .topic("A")
                    .startMessageIdInclusive()
                    .startMessageId(MessageId.latest)
                    .create();
if(reader.hasMessageAvailable()) {
    Message<byte[]> msg= reader.readNext();
}

Before executing the above code, I have produced many messages on that topic and as the result:

  • The msg that I get here is not the last message but the last message - 1 when I add .startMessageIdInclusive()
  • Without adding .startMessageIdInclusive(), reader.hasMessageAvailable() will return false.

Pulsar version that I used:

  • Version of pulsar jar: 2.5.0
  • Version of pulsar for run my pulsar instance: 2.7.0
@zymap
Copy link
Member

zymap commented Jan 28, 2021

@maimom1924 Looks like this issue already addressed by this PR #6362. You can try with 2.5.1 or higher version to test it.

@codelipenghui
Copy link
Contributor

@maimom1924 @zymap I will close this issue first, feel free to reopen it if needed.

@maimom1924
Copy link
Author

maimom1924 commented Jan 31, 2021 via email

@zymap zymap reopened this Feb 1, 2021
@zymap
Copy link
Member

zymap commented Feb 1, 2021

@maimom1924 I think it's the right behavior because you specified the startMessageIdInclusive which means you can read out the last message.

@maimom1924
Copy link
Author

maimom1924 commented Feb 1, 2021 via email

@zymap
Copy link
Member

zymap commented Feb 1, 2021

Yes. After reading the last message, then the reader. hasMessageAvailable will return false.

@maimom1924
Copy link
Author

@zymap I mean that the topic is completely empty, so the reader. hasMessageAvailable should return false, right? but I got true value.

@zymap
Copy link
Member

zymap commented Feb 2, 2021

Sorry for my misunderstanding. Yes, if the topic is empty, it should return false.

I found there has some PRs are fixing this issue: #9316 and #8735

@adrianog
Copy link

adrianog commented Apr 18, 2021

How do you use this in python? I see no provision at all for startMessageIdInclusive .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

No branches or pull requests

4 participants