google-cloud-platformgoogle-cloud-pubsubgoogle-cloud-pubsub-emulator

How to persist PubSub Emulator topics/subscriptions between restarts


Every time I restart the PubSub emulator, the topics/subscriptions are gone. Currently, I have a script that creates the topics and subscriptions each time the emulator starts:

https://stackoverflow.com/a/56994166/1237919

Is this state not persisted? Is there a way to persist state?


Solution

  • The emulator runs in memory; state is not persisted across runs. If you want to persist state, you will need to use the real Cloud Pub/Sub service. You could instead re-create your topics and subscriptions each time you start the emulator to get to the desired starting state.