0
0
GCPcloud~10 mins

Message retention and acknowledgment in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Message retention and acknowledgment
Message Published
Message Stored in Topic
Subscriber Receives Message
Subscriber Processes Message
Subscriber Sends Acknowledgment
Message Removed from Subscription
If No Ack Before Deadline
Message Redelivered
Messages are published and stored. Subscribers receive and process them, then send acknowledgment. If ack is missing before deadline, message is redelivered.
Execution Sample
GCP
Publish message -> Subscriber receives -> Process message -> Send ack -> Message removed
Shows the flow of message delivery, processing, acknowledgment, and removal from subscription.
Process Table
StepActionMessage StateAck DeadlineResult
1Message published to topicStored in topicN/AWaiting for subscriber
2Subscriber receives messageDelivered to subscriber10 secondsSubscriber starts processing
3Subscriber processes messageIn processing7 seconds leftProcessing ongoing
4Subscriber sends acknowledgmentAcknowledgedN/AMessage removed from subscription
5No new messageNo message pendingN/AWaiting for next message
6If ack not sent before deadlineNot acknowledged0 secondsMessage redelivered to subscriber
💡 Message removed after acknowledgment or redelivered if ack deadline missed
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 6
Message StateStored in topicDelivered to subscriberIn processingAcknowledgedRedelivered
Ack Deadline (seconds)N/A107N/A0
Key Moments - 3 Insights
Why does the message get redelivered even if it was already sent once?
If the subscriber does not send acknowledgment before the ack deadline (see step 6 in execution_table), the message is considered unprocessed and is redelivered to ensure it is handled.
What happens to the message after the subscriber sends acknowledgment?
According to step 4 in execution_table, once acknowledgment is sent, the message is removed from the subscription and will not be delivered again.
Does the message stay in the topic after delivery to subscriber?
Yes, the message stays in the topic. It is delivered to the subscription and tracked there until acknowledged or redelivered (see steps 1 and 2).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the message state after the subscriber sends acknowledgment?
AIn processing
BDelivered to subscriber
CAcknowledged
DStored in topic
💡 Hint
Check step 4 in the execution_table under 'Message State'
At which step does the message get redelivered if no acknowledgment is received?
AStep 3
BStep 6
CStep 4
DStep 2
💡 Hint
Look at the 'Result' column in step 6 of the execution_table
If the ack deadline is 10 seconds, what happens if the subscriber processes the message for 12 seconds without sending ack?
AMessage is redelivered after 10 seconds
BMessage stays in processing indefinitely
CMessage is removed immediately
DMessage is deleted from topic
💡 Hint
Refer to the ack deadline and redelivery logic in execution_table steps 2, 3, and 6
Concept Snapshot
Message retention means messages stay until acknowledged.
Subscribers must send acknowledgment before deadline.
If no ack, message is redelivered.
Ack removes message from subscription.
This ensures reliable message processing.
Full Transcript
In Google Cloud Pub/Sub, messages are published to a topic and stored until subscribers receive them. When a subscriber gets a message, it has a limited time called the acknowledgment deadline to process and acknowledge it. If the subscriber sends acknowledgment in time, the message is removed from the subscription and won't be sent again. If the subscriber fails to acknowledge before the deadline, the message is redelivered to ensure it is processed. This flow guarantees messages are not lost and are processed reliably.