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

pubsub: How to extend deadline past 600s? #608

Closed
purohit opened this issue Apr 21, 2017 · 4 comments
Closed

pubsub: How to extend deadline past 600s? #608

purohit opened this issue Apr 21, 2017 · 4 comments
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. type: question Request for information or clarification. Not an issue.

Comments

@purohit
Copy link

purohit commented Apr 21, 2017

Is it possible to modify a message's ack deadline multiple times to get a total deadline of > 600s? That is, if I have jobs which are queue-based, prone to failure, and yet take on average 2000s, I'd like to call modifyAckDeadline at appropriate intervals to extend the deadline lest another consumer receive the message during processing.

I see there's an API endpoint for it: https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline, but I'm not sure how to use this library to do it (or if multiple calls to modifyAckDeadline are even allowed; don't see anything in the docs about that). Right now I've set the ReceiveSettings.MaxExtension = 10 * time.Minute, but that only buys me the ten minutes up-front.

Thanks in advance for your help!

@pongad pongad added api: pubsub Issues related to the Pub/Sub API. type: question Request for information or clarification. Not an issue. labels Apr 24, 2017
@pongad
Copy link
Contributor

pongad commented Apr 24, 2017

@purohit The short version is ReceiveSettings.MaxExtension has you covered.

The slightly longer version: ReceiveSettings.MaxExtension and SubscriptionConfig.AckDeadline are different.

  • AckDeadline configures the pubsub server. If you don't ack or deadline-extend a message for this long, the server might redeliver the message.
  • MaxExtension configures the client. In the background, the client will automatically call modifyAckDeadline for you until MaxExtension has passed. After the time passes, the client assumes that you "lost" the message and stops extending.

Note that AckDeadline is still important. If the deadline is set too low, the client will need to call modifyAckDeadline often, which might slow you down. If the deadline is too high, the service will take a while to redeliver if your process crashes, etc.

For your use case, I think it's sufficient to set MaxExtension to something a little higher than 2000s.

@purohit
Copy link
Author

purohit commented Apr 24, 2017

@pongad Thanks for the thorough response. I'm really glad .MaxExtension has this behavior!

@TrangPham
Copy link

Does the python library also have the MaxExtension feature?

@pongad
Copy link
Contributor

pongad commented Dec 9, 2019

@TrangPham I don't think this is a good place to ask for details on Python lib. Can I point you to https://github.com/googleapis/google-cloud-python ? I'm 99.9% sure it does, but possibly in a different name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants