-
Notifications
You must be signed in to change notification settings - Fork 95
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 : add the concept of message abandonment #20
Comments
I would second this request. I need to be able to abort processing without what is essentially instantaneous redelivery. If I'm writing messages to a DB and the DB is down, for example, and will be down for an an extended period, there is no need or desire to instantaneous reprocess what would fail thousands and and thousands of times. But I dont want to throw it away, as service will eventually be restored. Simply nacking messages basically ensures I'm going to blow up my stackdriver logging costs, for example. It will result in potentially millions of unnecessary instant failed retry attempts, all logged and eating at my bill. The "abandoned" concept would allow the service to simply redeliver based on the subscription ack timeout, which at least is better than immediately, before any type of downstream service recovery has occurred. Or I could even ework with a .nack(redelivery_delay) call and manage the redelivery timing myself, per message. Native, innate, support for built in exponential backoffs for nacked messages, configured at the subscription level would be ideal, but I'll take anything at this point. |
Why was this feature reverted in 0.76.0? It was a great idea. |
@chingor13 Can you provide an insight as to why this was removed? |
The pub/sub team has to approve this feature request. |
@jadekler and @kolea2, can you please discuss this issue with the pub/sub team? |
The ack deadline is not intended as a way to delay delivery, but to signal that more time is needed to process a message. Delayed redelivery (and better control over redelivery semantics in general) is a useful feature and one we'd like to consider adding to the service, but we do not want to implement this feature just by overloading the meaning of ack deadline. This change will also need to be coordinated across all of the client library supported languages in order to maintain consistency. |
Please give me some way for my message subscriber to tell the library that I no longer want it to keep extending the deadline. Rename the method to |
@nhartner, if you simply stop extending the ack deadline, the Cloud Pub/Sub service will likely resend the exact same message back to you instantaneously once the most recent period expires. This means it will be sent back to you in 30 seconds (or whatever your configured ack extensions period is) instead of .5 seconds when you nack it. If you want to implement a per-message exponential backoff on another service (a database for example) you should consider implementing that in your own code, since Cloud Pub/Sub has no way of knowing what backoff pattern you would find acceptable. You can implement this in your message handler by performing x requests with y delay between them on failure, acking on any success and nacking on final failure. Google's api-client-library provides a useful utility for generating backoff times here. But simply not extending the deadline is not a useful answer, as it gives the user no control over when they want to retry. As an aside, if the answer to 'when to retry' is 'never', I would suggest using a dead letter queue pattern, where you publish unprocessable messages to a separate topic, ack them once publish is guaranteed, and handle them separately. |
@dpcollins-google I used the term For example ... given a
|
@dhoard Whether this is a common pattern is kind of orthogonal to the question of whether this is something that should be handled by pubsub. If you want to retry after 10 minutes, every 10 minutes, thats fine if that is the correct backoff strategy for whatever service that might fail that you're interacting with. I'd argue that that backoff strategy should be part of the client library for the service you're communicating with, not the Cloud Pub/Sub library. If you're making requests to an external service that might fail that does not implement a backoff strategy, the correct thing to do (in my opinion) would be to implement a backoff strategy appropriate for that service in that client library. |
@dpcollins-google your points are valid. @sduskis given the discussion above, I have no problem with closing this issue. For any possibly subscribers on the issue, something like the code below (not tested) could be used in your application to perform a simple delayed
|
Please note that @kolea2's response is still correct. We do agree this is a useful feature, but would want to ensure the service supports it natively rather than just using modify ack deadline for it. Delaying the nack on a message may have unintended consequences if flow control limits are set. These messages will count toward the outstanding messages and so more messages will not be delivered if enough message responses are delayed. We will provide updates when we have more to share on the possibility of supporting delayed redelivery for messages. |
@dhoard thanks for the suggested workaround. I'll be interested to play around with this. I suspect 100 threads is overkill since tasks are internally put in a queue by ScheduledThreadPoolExecutor and don't tie up a thread until they are ready to be processed. |
Since this request is more of a service-wide request and not something limited to the Java client library, we will track it via the issue tracker. I should also mention that there should be some news soon regarding features to support more control over retry semantics so that nacked messages won't come back to the subscriber immediately. |
Not directly related to abandoning a message, but for people who wanted to abandon because they wanted to use it to make PubSub redeliver the message with a delay, this info might be helpful. I noticed Pub/Sub supports retry policies 1 that are GA as of 2020-06-16 2.
|
PusubMessage
/AckReplyConsumer
needs the concept of "abandoning" a message.Abandoning a message would mean that the message ack deadline would no longer be auto-extended.
The text was updated successfully, but these errors were encountered: