Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Reader set to MessageId.latest and inclusive start message does not work #193

@Samreay

Description

@Samreay

Hi team,

When using start_message_id_inclusive, we expect the message seeked to be returned. This is the case for the pulsar.MessageId.earliest, but does not work with pulsar.MessageId.latest.

Reproduction

First, run a pulsar standalone instance:

docker run -it -p 6650:6650 -p 8080:8080 --tmpfs /pulsar/data apachepulsar/pulsar:3.1.0 bin/pulsar standalone

Then, run this code:

import pulsar

host = "pulsar://localhost:6650"
topic = "example"

client = pulsar.Client(host)
producer = client.create_producer(topic)
producer.send(b"Hello world 1!")
producer.send(b"Hello world 2!")

earliest_reader = client.create_reader(topic, pulsar.MessageId.earliest, start_message_id_inclusive=True)
msg = earliest_reader.read_next()
print(msg.value())
# Prints Hello world 1!, as wanted

latest_reader = client.create_reader(topic, pulsar.MessageId.latest, start_message_id_inclusive=True)
msg = latest_reader.read_next(timeout_millis=5000)
print(msg.value())
# Times out

The behaviour of the earliest reader is as expected. But the latest reader should not time out.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions