Google Professional Cloud Developer Question 209
Select 3Google Cloud PlatformYou are developing a serverless application that leverages Google Cloud Pub/Sub to handle messaging between services. To speed up development and reduce cloud usage costs, you decide to emulate Google Cloud services locally. Which of the following steps is necessary to emulate Pub/Sub locally and ensure smooth integration with your application?
- A
Install and configure the Google Cloud SDK for local development.
- B
Start the Cloud Pub/Sub emulator using the
gcloudCLI. - C
Update your application to use the emulator's endpoint instead of the default Pub/Sub endpoint.
- D
Deploy the application to Google Cloud to test emulator integration.
- E
Enable the Cloud Pub/Sub API in your Google Cloud project.
Show answer and explanation
Correct answers: A, B, C
Explanation
To emulate Google Cloud Pub/Sub locally, you need to configure your development environment by installing the Google Cloud SDK, starting the emulator, and updating your application's endpoint to point to the local emulator. This setup allows you to test Pub/Sub functionality locally without incurring cloud costs or requiring an active internet connection. Deploying to Google Cloud or enabling the Cloud Pub/Sub API is not relevant to local emulation scenarios.
- A. Correct.
Correct. The Google Cloud SDK includes tools like the Pub/Sub emulator, which is essential for local development and testing.
- B. Correct.
Correct. The Pub/Sub emulator must be explicitly started using the
gcloud beta emulators pubsub startcommand to simulate the service locally. - C. Correct.
Correct. Applications need to be configured to point to the emulator's endpoint (e.g., localhost) instead of the default Cloud Pub/Sub endpoint.
- D. Incorrect.
Incorrect. Deploying to Google Cloud defeats the purpose of local emulation. Emulators are specifically intended to test locally without deploying to the cloud.
- E. Incorrect.
Incorrect. Enabling the Cloud Pub/Sub API is necessary for actual cloud usage but is not required when working with the local emulator.