PROFESSIONAL-CLOUD-DEVELOPER · Question #288
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…
The correct answer is A. Create a push subscription with exactly-once delivery enabled. A push subscription with exactly-once delivery ensures each stock price update is processed exactly once with no duplicate messages, which is critical for financial data accuracy. Push delivery gives low-latency, real-time message delivery to the service updating the in-memory…
Question
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?
Options
- ACreate a push subscription with exactly-once delivery enabled.
- BCreate a pull subscription with both ordering and exactly-once delivery turned off.
- CCreate a pull subscription with ordering enabled, using the stock symbol as the ordering key.
- DCreate a push subscription with both ordering and exactly-once delivery turned off.
How the community answered
(37 responses)- A78% (29)
- B14% (5)
- C3% (1)
- D5% (2)
Explanation
A push subscription with exactly-once delivery ensures each stock price update is processed exactly once with no duplicate messages, which is critical for financial data accuracy. Push delivery gives low-latency, real-time message delivery to the service updating the in-memory database. Since each message already carries a timestamp, the application can use that field to discard out-of-order updates at the application level - only updating the database when the incoming message's timestamp is newer than the stored one. Option C (pull with ordering by stock symbol) would guarantee per-symbol ordering but can deliver duplicates and adds pull-loop complexity. Options B and D disable both ordering and exactly-once, risking stale or duplicate prices in the in-memory store.
Topics
Community Discussion
No community discussion yet for this question.