gcloud beta emulators pubsub - manage your local pubsub emulator
gcloud beta emulators pubsub COMMAND [--data-dir=DATA_DIR] [GCLOUD_WIDE_FLAG ...]
(BETA) This set of commands allows you to start and use a local Pub/Sub emulator to produce a local emulation of your production Google Pub/Sub environment. In addition to having Java JRE (of version 7 or higher) installed and an application built with Google Cloud Client libraries, you must have your emulator configured (have it started with environment variables set) for it to run successfully. The underlying commands help to set up this configuration.
To stop the emulator, press Ctrl+C.
For a more comprehensive overview of Pub/Sub, see https://cloud.google.com/pubsub/docs/overview. For Pub/Sub emulator specific documentation, see https://cloud.google.com/pubsub/docs/emulator
To start a local pubsub emulator with the default directory for configuration data, run:
$ gcloud beta emulators pubsub start
After starting the emulator, if your application and emulator run on the same machine, set environment variables automatically by running:
$ gcloud beta emulators pubsub env-init
If you're running your emulator on a different machine, run the above command and use its resulting output to set the environment variables on the machine that runs your application. This might look like:
$ export PUBSUB_EMULATOR_HOST=localhost:8538 $ export PUBSUB_PROJECT_ID=my-project-id
Your emulator is now ready for use.
- --data-dir=DATA_DIR
The directory to be used to store/retrieve data/config for an emulator run. The default value is <USER_CONFIG_DIR>/emulators/pubsub. The value of USER_CONFIG_DIR can be found by running:
$ gcloud info --format='get(config.paths.global_config_dir)'
These flags are available to all commands: --help.
Run $ gcloud help for details.
COMMAND is one of the following:
- env-init
(BETA) Print the commands required to export pubsub emulator's env variables.
- start
(BETA) Start a local pubsub emulator.
This command is currently in beta and might change without notice. This variant is also available:
$ gcloud alpha emulators pubsub