Duplicate messages
Cloud Pub/Sub guarantees at-least-once delivery of each message submitted to a topic. It does not, however, guarantee exactly-once delivery. Though typically rare, duplicate messages absolutely will occur, and so any service that consumes messages should be designed to handle duplicate messages. For example, suppose a customer loyalty service subscribes to a customer-orders topic and increases a customer's reward points whenever that customer places an order. The subscriber will eventually receive duplicate order-created messages for a customer order, and should be designed not to double-credit that user.
One common method for handling duplicate messages is to ensure any operations resulting from processing a message are ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access