In Google Cloud Pub/Sub, what happens if a subscriber does not acknowledge a message within the acknowledgement deadline?
Think about what happens when a message is not confirmed as received.
If a subscriber does not acknowledge a message within the acknowledgement deadline, Pub/Sub assumes the message was not processed and redelivers it to the same or another subscriber to ensure reliable delivery.
You want to send the same messages to multiple independent services using Pub/Sub. Which setup ensures each service receives all messages independently?
Remember that each subscription receives its own copy of messages.
In Pub/Sub, each subscription receives a copy of every message published to the topic. To deliver messages independently to multiple services, create one subscription per service on the same topic.
You want to allow only a specific service account to publish messages to a Pub/Sub topic. Which IAM role and policy setup achieves this?
Think about the role that allows publishing messages.
The 'roles/pubsub.publisher' role grants permission to publish messages to a topic. Assigning it to the service account on the topic resource restricts publishing to only that account.
Which configuration is required to enable a dead-letter topic for a Pub/Sub subscription?
Dead-letter topics require a policy on the subscription with delivery attempt limits.
To enable dead-lettering, you configure the subscription with a dead-letter topic and set the maximum number of delivery attempts before messages are sent to the dead-letter topic.
You have a subscriber processing messages that sometimes takes longer than the default acknowledgement deadline. What is the best practice to avoid message redelivery without losing messages?
Think about how to handle variable processing times safely.
Extending the acknowledgement deadline dynamically during message processing prevents premature redelivery while ensuring messages are acknowledged only after successful processing.