We all know that Pub/Sub subscribers being on the same subscription will share messages among them. I mean if two messages are on the queue (M1 and M2) and two subscribers S1 and S2 are on the same subscription listening to that queue, S1 takes care of M1 and S2 takes care of M2. What if let's say S2 subscriber process crashes while processing M2? How Cloud Pub/Sub handles this kind of failover?
1
votes
1 Answers
0
votes
If a subscriber crashes before acknowledging a message, then the message will be delivered again to a subscriber after the ack deadline has passed (and assuming the message has not been unacknowledged for the maximum retention time period, which defaults to seven days). In your scenario, if S2 never comes back, then the message will be delivered to S1. If S2 does come back up, then the message could be delivered to either S1 or S2. Once an acknowledgement has been successfully processed (note that acks are best effort and therefore duplicate delivery can occur), the message will no longer be delivered to subscribers. The At-Least-Once Delivery section of the documentation explains in a little more detail.