professional-cloud-data-engineer
Prepare and test your skills
Prepare and test your skills
Worked example. The correct answer is already marked and every option is explained below, so there is nothing to select here. To answer questions yourself, start the free trial.
Your team is designing an event-driven data pipeline using Eventarc to trigger a Cloud Run microservice whenever a new file is uploaded to Cloud Storage. The microservice processes the file and updates a stateful database.
Because Eventarc guarantees at-least-once delivery, the microservice occasionally receives duplicate events for the same file upload, causing duplicate database entries. You need to implement a solution to prevent data duplication and ensure the database is only updated once per event.
What should you do?
The xgooglemessageuid is a CloudEvents attribute provided by Eventarc that uniquely identifies the action of publishing an event. It acts as a unique identifier for every distinct event routed through the system.
By extracting this unique identifier from the incoming event payload, the microservice can perform a transactional check against the database (such as querying a table of processed event IDs) before applying the update. If the ID is already present, the service recognizes the event as a duplicate and safely ignores it, effectively achieving exactly-once processing semantics.
Eventarc guarantees at-least-once delivery, meaning duplicate events can and will occur due to network retries or service restarts. The most robust architectural pattern to handle this is designing the receiving service to be idempotent. Using the built-in xgooglemessageuid for deduplication via an external transactional check is the recommended approach for state management in event-driven systems.
Keep the momentum going with these hand-picked practice scenarios
Want more questions like this?
Get a free certification question every week.