You need fast local testing of Pub/Sub integration for new builds. How should you configure local testing?
Choose an answer
Tap an option to check your answer.
Correct answer: Install the Pub/Sub emulator with gcloud, start it with a valid project ID, and point your app to it by exporting PUBSUB_EMULATOR_HOST..
Why this is the answer
The Pub/Sub emulator provides a local, in-memory version of the Pub/Sub service, ideal for fast, offline testing without incurring costs or affecting production data. You install it via gcloud components install pubsub-emulator, start it with gcloud beta emulators pubsub start --project=your-project-id, and then configure your application to use it by setting the PUBSUBEMULATORHOST environment variable to the emulator's address (e.g., localhost:8085). Enabling the Pub/Sub API in Cloud Console and calling pubsub.googleapis.com would connect to the live cloud service, which is not suitable for local, fast, and isolated testing. Running a gcloud configuration command to set an endpoint override is not the standard or recommended way to connect to the Pub/Sub emulator; the PUBSUBEMULATORHOST environment variable is the correct mechanism. While Cloud Code can assist with local development, it doesn't inherently provide a local Pub/Sub emulator or change how your application connects to it; it would still require the emulator setup for local testing.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed