
Answer-first summary for fast verification
Answer: Create a Pub/Sub snapshot before deploying new subscriber code. Use a Seek operation to re-deliver messages that became available after the snapshot was created.
The correct answer is B. Creating a Pub/Sub snapshot before deploying new subscriber code and using a Seek operation to re-deliver messages that became available after the snapshot was created allows you to recover from potential errors. This approach preserves the state of unacknowledged messages and ensures that you can reset the subscription's acknowledgment state to avoid message loss. Options A, C, and D do not effectively address the issue of messages being erroneously acknowledged and lost.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You are tasked with updating the code for a subscriber within a Google Cloud Pub/Sub architecture. The subscriber currently processes incoming messages from a Pub/Sub topic. However, there is a concern that during deployment, the subscriber may inadvertently acknowledge messages before they have been properly processed, resulting in potential message loss. Currently, the system is configured such that once messages are acknowledged, they are not retained. What steps should be taken to ensure error recovery and prevent message loss during and after the deployment process?
A
Set up the Pub/Sub emulator on your local machine. Validate the behavior of your new subscriber logic before deploying it to production.
B
Create a Pub/Sub snapshot before deploying new subscriber code. Use a Seek operation to re-deliver messages that became available after the snapshot was created.
C
Use Cloud Build for your deployment. If an error occurs after deployment, use a Seek operation to locate a timestamp logged by Cloud Build at the start of the deployment.
D
Enable dead-lettering on the Pub/Sub topic to capture messages that aren't successfully acknowledged. If an error occurs after deployment, re-deliver any messages captured by the dead-letter queue.