nerdexam
Google

PROFESSIONAL-CLOUD-DEVELOPER · Question #292

You have a web application that publishes messages to Pub/Sub. You plan to build new versions of the application locally and need to quickly test Pub/Sub integration for each new build. How should…

The correct answer is B. Install the Pub/Sub emulator using gcloud, and start the emulator with a valid Google Project ID. The Pub/Sub emulator, installed via gcloud components install pubsub-emulator, provides a local Pub/Sub server that mimics the real service without incurring costs or requiring network access. You start it with a valid project ID, then set the PUBSUB_EMULATOR_HOST environment…

Developing, deploying, and debugging applications

Question

You have a web application that publishes messages to Pub/Sub. You plan to build new versions of the application locally and need to quickly test Pub/Sub integration for each new build. How should you configure local testing?

Options

  • AIn the Google Cloud console, navigate to the API Library, and enable the Pub/Sub API. When
  • BInstall the Pub/Sub emulator using gcloud, and start the emulator with a valid Google Project ID.
  • CRun the gcloud config set api_endpoint_overrides/pubsub
  • DInstall Cloud Code on the integrated development environment (IDE). Navigate to Cloud APIs,

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    90% (28)
  • C
    6% (2)

Explanation

The Pub/Sub emulator, installed via gcloud components install pubsub-emulator, provides a local Pub/Sub server that mimics the real service without incurring costs or requiring network access. You start it with a valid project ID, then set the PUBSUB_EMULATOR_HOST environment variable so your application connects to the local endpoint. This is the fastest and cheapest way to iterate locally. Option A enables the real API, which means each test build hits production infrastructure and incurs latency and costs. Option C attempts to override the API endpoint via gcloud config, which is not the standard or supported local-testing approach. Option D (Cloud Code) is an IDE plugin that primarily helps deploy to real GCP environments, not a local emulator solution.

Topics

#Pub/Sub#Local Development#Emulators#Testing

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice