Cloudfunction with pubsub trigger queuing the messages

We have a Cloudfunction with a Pubsub trigger and it will invoke an application on HTTP endpoint based on the message. When we need to update the backend application we want the Cloudfunction to pause and queue up the messages and then start again when the application is up.

Currently we are logging all the failed messages in Stackdriver and resubmitting them after the release. Is there any better way to do this?

1 answer

  • answered 2021-06-17 07:27 guillaume blaquiere

    Your system must be resilient to outage (managed by you when you perform an update, or unexpected). Therefore, I recommend you to handle both in the same way.

    Set the retry parameter when you deploy your Cloud Functions (background functions, bind with PubSub topic). When your Cloud Functions can't process the message (the application isn't available), raise an error. The message will be retried later.

    Like that, you have nothing to worry. When the message can be delivered, it is, and when it can't, there is an error and the message is retried.