gcloud beta emulators pubsub

NAME
gcloud beta emulators pubsub - manage your local pubsub emulator
SYNOPSIS
gcloud beta emulators pubsubCOMMAND[--data-dir=DATA_DIR][GCLOUD_WIDE_FLAG]
DESCRIPTION
(BETA) This set of commands allows you to start and use a localPub/Sub emulator to produce a local emulation of your production Google Pub/Subenvironment. In addition to having Java JRE (of version 7 or higher) installedand an application built with Google Cloud Client libraries, you must have youremulator configured (have it started with environment variables set) for it torun 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, seehttps://cloud.google.com/pubsub/docs/overview.For Pub/Sub emulator specific documentation, seehttps://cloud.google.com/pubsub/docs/emulator

EXAMPLES
To start a local pubsub emulator with the default directory for configurationdata, run:
gcloudbetaemulatorspubsubstart

After starting the emulator, if your application and emulator run on the samemachine, set environment variables automatically by running:

gcloudbetaemulatorspubsubenv-init

If you're running your emulator on a different machine, run the above commandand use its resulting output to set the environment variables on the machinethat runs your application. This might look like:

exportPUBSUB_EMULATOR_HOST=localhost:8538exportPUBSUB_PROJECT_ID=my-project-id

Your emulator is now ready for use.

FLAGS
--data-dir=DATA_DIR
The directory to be used to store/retrieve data/config for an emulator run. Thedefault value is<USER_CONFIG_DIR>/emulators/pubsub. Thevalue of USER_CONFIG_DIR can be found by running:
gcloudinfo--format='get(config.paths.global_config_dir)'
GCLOUD WIDE FLAGS
These flags are available to all commands:--help.

Run$gcloud help for details.

COMMANDS
COMMAND is one of the following:
env-init
(BETA) Print the commands required to export pubsub emulator's envvariables.
start
(BETA) Start a local pubsub emulator.
NOTES
This command is currently in beta and might change without notice. This variantis also available:
gcloudalphaemulatorspubsub

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-05-07 UTC.