1
votes

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.

1

1 Answers

2
votes

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.