Reader does not return any message when configured with reading inclusive latest messageId
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 142
Description
**Describe the bug**
Creating reader with messageId pointing to `MessageId.latest` together with `startMessageIdInclusive`,there is no message returned when `readNext` is invoked. Newly coming messages are consumed. When using `MessageId.earliest`, a message is returned - means there are messages in that topic.
Having running local docker image with puslar 2.7.1 and java client 2.7.1
**Steps To Reproduce**
```
pulsarClient.newReader(JSONSchema.of(MySchema.class))
.topic(topic)
.startMessageId(MessageId.latest)
.startMessageIdInclusive().create()
.readNext(250, TimeUnit.MILLISECONDS)
```
**Expected behavior**
Last message in queue is returned when calling `Reader.readNext` with Reader configuration` MessageId.latest` and `startMessageIdInclusive()`
**Similar Issue**
Seems, it was already reported in [issue 4912](https://github.com/apache/pulsar/issues/4912) in first paragraph **Test3**
> Test3:When configuring Reader with startMessageIdInclusive and positioning stream at MessageId.latest, then the next call to Reader.readNext(timeout) should have returned the last message of the topic, but it times out and returns null (without a configured timeout it blocks forever).
.....
Expected behavior
test3 expected to return the last message in topic, test4 hasMessageAvailable expected to be false.
but it is little bit confusing because underlying method `readMessage` starts with `hasMessageAvailable()` which in that time returns wrongly true and `readNext` is reached but no message is returned, but should be.
Contributor guide
Research direction
Reproduce the Java client case using MessageId.latest, startMessageIdInclusive(), and Reader.readNext, then trace the related hasMessageAvailable() and readMessage() entry points. Compare the behavior with the earlier issue 4912; done means the latest existing message is returned while newly arriving messages remain consumable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100