Pulsar reader doesn't return correct last message with startMessageIdInclusive()
See original GitHub issueI 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 butthe 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:
- Created 3 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
@maimom1924 @zymap I will close this issue first, feel free to reopen it if needed.