How to prevent duplicate processing in Pub/Sub pull subscriptions?

PDE By islever Editorial Last updated

Short answer

C Use Pub/Sub exactly-once delivery in your pull subscription.

Question

Your chemical company needs to manually check documentation for customer order. You use a pull subscription in Pub/Sub so that sales agents get details from the order. You must ensure that you do not process orders twice with different sales agents and that you do not add more complexity to this workflow. What should you do?
  1. Use a Deduplicate PTransform in Dataflow before sending the messages to the sales agents.
  2. Create a transactional database that monitors the pending messages.
  3. Use Pub/Sub exactly-once delivery in your pull subscription. Correct Answer
  4. Create a new Pub/Sub push subscription to monitor the orders processed in the agent's system.

Key Takeaways

This question tests knowledge of native Pub/Sub features, specifically exactly-once delivery, while trapping candidates who might over-engineer a solution using Dataflow or databases.

To prevent duplicate message processing in Google Cloud Pub/Sub pull subscriptions without adding workflow complexity, you should utilize the platform's native exactly-once delivery feature. The community confirms this is the most efficient method compared to external solutions like Dataflow.

Common mistake: Choosing Option A (Dataflow Deduplicate PTransform) is a common mistake because, while it solves the deduplication issue, it violates the requirement to avoid adding complexity to the workflow.

Expert Analysis

Why the Answer Is Correct

Option C is correct because Google Cloud Pub/Sub offers exactly-once delivery, which ensures that each message is delivered to the subscriber exactly once, even in the event of network errors or retries. This feature directly addresses the requirement to prevent orders from being processed twice by different sales agents. It achieves this natively without requiring additional infrastructure, thereby adhering to the constraint of not adding complexity to the workflow.

Why the Other Options Are Wrong

Option A is incorrect because using a Deduplicate PTransform in Dataflow introduces an additional data processing pipeline, which significantly increases architectural and operational complexity. Option B is incorrect because implementing a transactional database to monitor messages requires custom state management and infrastructure, adding unnecessary overhead. Option D is incorrect because switching to a push subscription does not inherently solve the deduplication requirement and alters the existing workflow architecture without providing a clear benefit for preventing duplicate processing.

Community Comment Notes

The community strongly supports Option C, with multiple users citing the official Google Cloud documentation on exactly-once delivery. Comment [4] provides a detailed explanation of why Option A is incorrect, specifically noting that Dataflow adds complexity that contradicts the question's constraints. While comment [5] raises a theoretical concern about multiple subscribers, the consensus remains that exactly-once delivery is the intended solution for the described scenario.

Official Reference

https://cloud.google.com/pubsub/docs/exactly-once-delivery

This link opens the official vendor documentation in a new tab.

Exam Strategy

When answering questions about data reliability, always prioritize native service features over building custom solutions or adding complex pipelines. Look for keywords like 'complexity' or 'maintenance' as indicators to choose the simplest, managed service option.

Community Votes

C
100%

100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 7 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 7

  1. meh_33 👍 12
    Believe me all questions were from Exam topic all were there yesterday in exam. But yes dont go with starting questions mainly focus questions after 200 and latest questions are at last page.
  2. JimmyBK 👍 7 Answered C
    I remember seeing this in the exam.
  3. AllenChen123 👍 4 Answered C
    Straightforward. https://cloud.google.com/pubsub/docs/exactly-once-delivery
  4. Pime13 👍 1 Answered C
    https://cloud.google.com/pubsub/docs/exactly-once-delivery Option A, using a Deduplicate PTransform in Dataflow, could help remove duplicate messages, but it adds complexity to your workflow. Dataflow is a separate service that would need to be integrated and managed, which might not be necessary if Pub/Sub's exactly-once delivery can handle the deduplication for you. Using Pub/Sub's exactly-once delivery (Option C) is a more straightforward solution that directly addresses the issue of duplicate processing without adding extra components to your system.
  5. cien91 👍 1 Answered A
    Why not C - Exactly-once delivery in Pub/Sub guarantees that a message is delivered to a subscriber exactly once. However, it doesn't prevent multiple subscribers from processing the same message.
Show 2 more comments
  1. Sofiia98 👍 1 Answered C
    C, of course
  2. JyoGCP 👍 1 Answered C
    Option C

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

← Back to PDE Study Guide