apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.15k stars 3.57k forks source link

As a websocket consumer I need to set InitialSubscriptionPosition to earliest #22969

Closed moinessim closed 2 months ago

moinessim commented 3 months ago

Search before asking

Motivation

As a websocket client, I need to subscribe to a persistent topic that has existing messages. I need to consume all messages, starting from the first (earliest) one, and keep consuming messages as they become available. Persistent subscription cursor is needed, hence the use of consumer api.

There is no parameter available for this setting shown in the documentation, or in the code that creates the subscription.

There is a similar setting messageId for the Reader endpoint. But not for the Consumer endpoint.

Solution

Receive a new url parameter "initialSubscriptionPosition", and add the value to the consumer builder using the corresponding java api method.

Alternatives

Use the Reader endpoint: I would really prefer Pulsar to handle the cursor, instead of having to manage that state.

Anything else?

I would be open to implement this myself, if needed.

Thank you very much for your contributions!

Are you willing to submit a PR?

lhotari commented 2 months ago

Makes sense to add support for initialSubscriptionPosition