Google Cloud Professional Cloud Developer — Question 267
You recently developed an application that monitors a large number of stock prices. You need to configure Pub/Sub to receive messages and update the current stock price in an in-memory database. A downstream service needs the most up-to-date prices in the in-memory database to perform stock trading transactions. Each message contains three pieces or information:
• Stock symbol
• Stock price
• Timestamp for the update
How should you set up your Pub/Sub subscription?
Answer options
- A. Create a push subscription with exactly-once delivery enabled.
- B. Create a pull subscription with both ordering and exactly-once delivery turned off.
- C. Create a pull subscription with ordering enabled, using the stock symbol as the ordering key.
- D. Create a push subscription with both ordering and exactly-once delivery turned off.
Correct answer: C
Explanation
Option C is correct because enabling ordering with the stock symbol as the key ensures that updates for the same stock are processed in the correct sequence, which is crucial for accurate trading. Option A is incorrect as push subscriptions might not guarantee ordering. Option B does not address the need for ordering, which is essential for handling stock updates effectively. Option D also lacks ordering, which is necessary for ensuring the most recent prices are used in trading transactions.