Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java-client] ConsumerBuilder should have option for defaultSubscriptionInitialPosition #4928

Closed
kimcs opened this issue Aug 9, 2019 · 3 comments
Labels
area/client deprecated/question Questions should happened in GitHub Discussions

Comments

@kimcs
Copy link
Contributor

kimcs commented Aug 9, 2019

Is your feature request related to a problem? Please describe.
Using the java client, I am unable to continue a subscription from where it was last acknowledged, or from the very beginning of the topic if no such ack is recorded or the subscription is new. If I provide an earliest or latest value to the subscriptionInitialPosition then that value is used instead of continuing from where the subscription was last acked, hence the need for to provide a default when subscribing.

Describe the solution you'd like
Add an option defaultSubscriptionInitialPosition(SubscriptionInitialPosition) to ConsumerBuilder that controls where the subscription should start reading if the subscription is new or has never received an ack.

Describe alternatives you've considered

  1. The default setting of starting a subscription after the most-recent-message (end) of the topic could be controlled at the broker, tenant, namespace or topic level. Any of these alternatives provide less control and ease-of-use than the suggested solution.

  2. Provide a method to read out the last acked message-id directly from the PulsarClient, and combine this with consumer building options similar to the startMessageId and startMessageIdInclusive options of the ReaderBuilder interface. I think this option is less intuitive than having a default initial position option.

  3. Change the behaviour of the current ConsumerBuilder.subscriptionInitialPosition option to use the provided value as a default, but to always continue where the subscription last left-off if an ack has been made on this subscription earlier. This alternative will change the behaviour of existing clients, and is therefore not backwards-compatible, so I would not recommend it.

@kimcs kimcs added the type/feature The PR added a new feature or issue requested a new feature label Aug 9, 2019
@kimcs
Copy link
Contributor Author

kimcs commented Aug 14, 2019

I have changed my design and now rely on the pulsar client application to track positions rather than using subscriptions and acknowledgements, so I no longer need this feature for what I'm working on. Still I think this option is useful, as it allows using Pulsar subscriptions to be master of stream progress with at-least-once semantics.

@sijie
Copy link
Member

sijie commented Jul 28, 2020

@kimcs

ConsumerBuilder.subscriptionInitialPosition is only applied to the subscription that doesn't exist before. If there is already a subscription created, the consumer will start from where it was left. Hence the existing behavior of ConsumerBuilder.subscriptionInitialPosition already meets your requirements. Is that correct?

@tisonkun
Copy link
Member

tisonkun commented Dec 9, 2022

Closed as answered.

@tisonkun tisonkun closed this as completed Dec 9, 2022
@tisonkun tisonkun added deprecated/question Questions should happened in GitHub Discussions and removed type/feature The PR added a new feature or issue requested a new feature lifecycle/stale labels Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client deprecated/question Questions should happened in GitHub Discussions
Projects
None yet
Development

No branches or pull requests

4 participants