question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zymapcommented, 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

1reaction
codelipenghuicommented, Jan 30, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pulsar 2.5.0 regression: Reader.hasMessageAvailable returns ...
Reader.hasMessageAvailable returns false when startMessageId is the message id of the last message id in startMessageIdInclusive mode. If the ...
Read more >
ConsumerBuilder (Pulsar Client :: API 2.9.0-SNAPSHOT API)
Ack will return receipt but does not mean that the message will not be resent after get receipt. ... Consumer<T> subscribe() throws PulsarClientException....
Read more >
pulsar - Go Packages
The message id can either be a specific message or represent the first or last messages in the topic. // // Note: this...
Read more >
009 - Apache Pulsar Connector - Hazelcast Jet
But, since this API does not return the cursor for the last consumed message, it is incapable of assuring fault-tolerance. This issue will...
Read more >
org.apache.pulsar.client.api.Reader Java Examples
assertTrue(keys.remove(reader.readNext().getKey())); } // start from latest with start message inclusive should only read the last message in batch Assert.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found