QuestionQ245

Integrating applications with Google Cloud services

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

  • A In the Google Cloud console, navigate to the API Library, and enable the Pub/Sub API. When developing locally configure your application to call pubsub.googleapis.com.
  • B Install the Pub/Sub emulator using gcloud, and start the emulator with a valid Google Project ID. When developing locally, configure your applicat.cn to use the local emulator by exporting the PUBSUB_EMULATOR_HOST variable.
  • C Run the gcloud config set api_endpoint_overrides/pubsub https://pubsubemulator.googleapis.com.com/ command to change the Pub/Sub endpoint prior to starting the application.
  • D Install Cloud Code on the integrated development environment (IDE). Navigate to Cloud APIs, and enable Pub/Sub against a valid Google Project IWhen developing locally, configure your application to call pubsub.googleapis.com.
Explanation

The Pub/Sub emulator provides a local emulation of the production Pub/Sub service for development and testing. Install and start it with the Google Cloud CLI, then set PUBSUB_EMULATOR_HOST so the application’s Pub/Sub client connects to the local emulator instead of the production service.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!