In Google Cloud Pub/Sub, when a subscriber receives a message, what happens if the subscriber does not acknowledge the message within the acknowledgment deadline?
Think about what happens when a message is not confirmed as processed in time.
If a subscriber does not acknowledge a message within the acknowledgment deadline, Pub/Sub assumes the message was not processed and makes it available for redelivery to the same or another subscriber.
You want to ensure that unacknowledged messages in a Pub/Sub subscription are retained for 7 days before being deleted. Which configuration should you set?
Retention duration controls how long messages stay in the subscription after delivery.
The messageRetentionDuration on the subscription controls how long unacknowledged messages are retained before deletion. Setting it to 7 days keeps messages for that duration.
You have a subscriber that processes messages slowly, sometimes taking longer than the default acknowledgment deadline. What is the best practice to prevent message loss or duplicate processing?
Think about how to keep the message invisible to others while processing.
Extending the acknowledgment deadline dynamically allows the subscriber to keep the message invisible to others while processing, preventing premature redelivery and duplicate processing.
What happens to a message in a Pub/Sub subscription configured with a dead-letter topic if the message is not acknowledged after the maximum delivery attempts?
Dead-letter topics are used to handle problematic messages.
When a message exceeds the maximum delivery attempts without acknowledgment, Pub/Sub sends it to the configured dead-letter topic for separate handling.
You are designing a system that must process messages exactly once using Google Cloud Pub/Sub. Which combination of features and practices will best help achieve this?
Consider how to handle duplicates and failures safely.
Pub/Sub provides at-least-once delivery, so to achieve exactly-once processing, the subscriber must handle duplicates. Using dead-letter topics helps manage failed messages safely.