Skip to content

Reader.has_message_available() returns True even if no messages to consume, when start_message_id is earliest #199

@adamdelezuch89

Description

@adamdelezuch89

Hi,
Reader.has_message_available() returns True on first execution, even if no message available on topic. Issue is only, when reader is created with start_message_id=pulsar.MessageId.earliest,

Environment:
Python 3.11.5
pulsar-client 3.4.0

Reproduction

  1. Create reader with start_message_id=pulsar.MessageId.earliest:
from my_schemas import Schema
import pulsar

pulsar_url = "localhost"
topic = "tenant/namespace/topic"
name = "name"
schema = pulsar.schema.AvroSchema(Schema)

client = pulsar.Client(pulsar_url)

reader = client.create_reader(
    topic=topic,
    start_message_id=pulsar.MessageId.earliest,
    schema=schema,
    reader_name=name,
)
  1. Seek MessageId.latest or timestamp after point, where is no more messages
reader.seek(pulsar.MessageId.latest)
  1. read messages until no more messages available
while reader.has_message_available(): # It is True on first iteration but should be False
    msg = reader.read_next(timeout_millis=5000)

print("No more messages")

At point 3 I should get info log "No more messages", but I got Timeout exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions