2

I have a push subscription that sends message to a Cloud Run service. If the Cloud Run service does not acknowledge the message successfully (negative acknowledgement) I want to resend the message a maximum number of times with always the same time interval between retries (e.g. 10 retries with each retry after 1 min.).

  1. I know I can set the maximum number of times a message is resend with a dead letter queue (Can I also set this number without a dead letter queue? So just discard/remove the message after a max. number of delivery attempts without the message going to another queue?).
  2. Also with the retry policy I can set the minimum backoff (e.g. 1 min.) to decide after what time the first retry will happen but after that PubSub's retry policy uses some exponential delay. Can I not specify here a linear delay (always same time interval)?

Is this possible somehow with the PubSub push subscription settings mentioned here https://cloud.google.com/pubsub/docs/admin#using_subscription_properties?

Thanks in advance for any help.

Michael W.
  • 107
  • 8

1 Answers1

5

Prior to answering your questions we must look at how pubsub handles retry:

By default pubsub will try to send the message until it is unacked as the design of Pub/Sub is to implement At least once delivery. The resending of messages will continue depending on the message retention duration that is set (between 10 mins to 7 days).

  1. Considering the behavior of pubsub, the only way is using a dead letter queue as you have mentioned.

  2. The retry policy is either retry immediately or retry after exponential backoff delay. You cannot configure a linear delay on both options. The exponential backoff is being handled by the API and is subject to change overtime as per this SO answer. A possible workaround if you are implementing "nack", you can select "retry immediately" and add a delay on your script before performing a "nack". With this, you can control a fixed delay for your nacked messages.

Ricco D
  • 6,873
  • 1
  • 8
  • 18
  • Thank you for the answer. I would like to avoid adding a delay to my script since there could be thousands of messages that need to be resend. Then if I use the retry policy with exponential backoff delay: I would like the time interval between 2 retries to be more than 10 min. at some point (e.g. after 2h of retries it should be at approx. 30 min.). Since the maximum backoff duration (time interval between retries) can be 10 min. at max is this not possible with the PubSub settings? – Michael W. Oct 15 '21 at 12:32
  • @MichaelW. Unfortunately it is not possible to go beyond 10 mins as this is a current limitation of the API. – Ricco D Oct 18 '21 at 01:30