Google Cloud Platform – How to Reattach PubSub Subscription to Topic

google-cloud-platform

In Google Cloud PubSub you tipically have subscriptions attached to a topic. I saw a new option to "detach" a subscription from the topic.

My app was having issues so I detached the subscription from the topic instead of deleting it, I thought it was an easy way to "give my app a break". The issue is, it seems that I cannot reattach the subscription to the topic anymore.

According to this document I can infer that it is not possible to get a subscription to reattach to a topic: https://cloud.google.com/pubsub/docs/admin#detaching_subscriptions

My questions are:

  1. is there a way to reactivate a subscription after it has been detached (I assume no).
  2. what is the recommended way to put a "pause" to a subscription in order to give my system some breath room until I get it back up?

Thanks for your help 🙂

Best Answer

As per the GCP documentation,

After the Pub/Sub service detaches the subscription from the topic, the Pub/Sub service deletes any messages that it retains for the subscription. You can't retrieve these messages from the subscription or reattach the subscription to a topic.


Regarding the pause, there is no such option, however, if you are having a pull subscription, you control when to initiate requests to the Pub/Sub server to retrieve messages.

Thus, if you are having a push subscription, you can change it to pull in order to temporarily stop Pub/Sub from sending requests to the push endpoint, and then set the URL to a valid endpoint again to resume push delivery - Stopping and resuming delivery.

Related Topic