user2824203
user2824203

Reputation: 145

Pubsub push to pull subscriptions

I am moving from push to pull subscriptions. Given that I have several instances of my service running, during the deployment rollout both push and pull will be in play until all instances are updated. I do not want to loose message events or have events both pushed and pulled. Would it be best practice to simply have separate versions of both topics and subscriptions for pull and then remove the old push ones in a second deployment after the topics are drained? Or is there a better way to do this?

Upvotes: 0

Views: 1185

Answers (1)

Kamal Aboul-Hosn
Kamal Aboul-Hosn

Reputation: 17161

In transitioning from push to pull, you should not lose any messages; Cloud Pub/Sub handles this transition. However, there would be no way to guarantee that events are not going to be received by both a push subscriber and a pull subscriber during the transition if they are running simultaneously given because Cloud Pub/Sub only has at-least-once delivery guarantees and the transition from push to pull is an eventually consistent change across the system.

If that is a strict requirement, then there are a couple of options:

  1. Use a separate topic and subscription and publish messages to only one of the topics. This does mean you need to transition your publishers to the new topics.
  2. Change the subscription from a push subscription to a pull subscription (by removing the push endpoint from the subscription configuration) and wait until the push subscriber stops receiving messages. This should probably take a few minutes. Once that has happened, it means the transition from push to pull has completed. After that, you could bring up your pull subscribers. This does mean a brief period of downtime for your subscribers during the transition.

The choice comes down to a choice between having to update publishers to send messages to a different topic or a transient downtime for processing the messages in the subscribers.

Upvotes: 2

Related Questions