nerdexam
GoogleGoogle

PROFESSIONAL-DATA-ENGINEER · Question #360

PROFESSIONAL-DATA-ENGINEER Question #360: Real Exam Question with Answer & Explanation

Option B is correct because the Dataflow job acknowledges the message before applying business logic, meaning Pub/Sub considers the message successfully delivered regardless of what happens in the DoFn. The only way to capture a business logic failure is to handle it programmatic

Submitted by ricky.ec· Mar 30, 2026Designing data processing systems

Question

Your car factory is pushing machine measurements as messages into a Pub/Sub topic in your Google Cloud project. A Dataflow streaming job, that you wrote with the Apache Beam SDK, reads these messages, sends acknowledgment to Pub/Sub, applies some custom business logic in a DoFn instance, and writes the result to BigQuery. You want to ensure that if your business logic fails on a message, the message will be sent to a Pub/Sub topic that you want to monitor for alerting purposes. What should you do? topic. Use Cloud Monitoring to monitor the topic/num_unacked_messages_by_region metric on this new topic.

Options

  • CEnable dead lettering in your Pub/Sub pull subscription, and specify a new Pub/Sub topic as the dead letter topic. Use Cloud Monitoring to monitor the
  • DCreate a snapshot of your Pub/Sub pull subscription. Use Cloud Monitoring to monitor the snapshot/num_messages metric on this snapshot.

Explanation

Option B is correct because the Dataflow job acknowledges the message before applying business logic, meaning Pub/Sub considers the message successfully delivered regardless of what happens in the DoFn. The only way to capture a business logic failure is to handle it programmatically inside the DoFn itself - catch the exception and explicitly publish the failed message to a separate error Pub/Sub topic, then monitor that topic.

Why C is wrong: Dead lettering only activates when Pub/Sub cannot deliver a message or a message exceeds the maximum delivery attempts. Since the job already sent the acknowledgment before the DoFn runs, Pub/Sub has no visibility into the downstream failure - the dead letter mechanism is never triggered.

Why D is wrong: A Pub/Sub subscription snapshot is a point-in-time capture of the unread message backlog, used for replaying messages to multiple subscriptions. It does not track processing failures and the snapshot/num_messages metric has nothing to do with business logic errors.

Memory tip: Think of the ack as a "receipt" - once Pub/Sub gets its receipt, it stops caring about the message. If you want to catch failures after the receipt is issued, you must do it yourself inside the code (DoFn try/catch → publish to error topic). Dead lettering only helps before the receipt is handed over.

Topics

#Dataflow#Apache Beam#Error Handling#Pub/Sub

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-DATA-ENGINEER PracticeBrowse All PROFESSIONAL-DATA-ENGINEER Questions