Message ID stability across subscription-driven retries

39 views
Skip to first unread message

Pedro Yan Ornelas

unread,
Jun 6, 2022, 10:49:07 AM6/6/22
to pubsub-discuss
Hi there, 

Is the message ID stable across delivery retries managed by Pub/Sub? I was under the impression that would be stable and could be used as an idempotency key, however, I couldn't find anything in the docs regarding this topic

Jose Gutierrez Paliza

unread,
Jun 6, 2022, 1:30:40 PM6/6/22
to pubsub-discuss

Pub/Sub automatically assigns a unique message_id to each message successfully published to a topic. Each message is considered successfully published by the publisher when Pub/Sub returns an acknowledgement to the publisher. Within a topic all messages have a unique message_id and no two messages have the same message_id. If success of the publish is not observed for some reason (network delays, interruptions etc) the publisher may retry the same message payload. If retries happen, we may end up with duplicate messages with different message_id in Pub/Sub. For Pub/Sub these are unique messages as they have different message_id.

In general, Pub/Sub delivers each message once and in the order in which it was published. However, messages may sometimes be delivered out of order or more than once. Accommodating more-than-once delivery requires your subscriber to be idempotent when processing messages.

[1]https://cloud.google.com/pubsub/docs/subscriber#default-properties
Reply all
Reply to author
Forward
0 new messages