A Dataflow streaming job reads Pub/Sub, a DoFn applies business logic and writes to BigQuery. If the DoFn fails for a message, you want that message sent to a Pub/Sub topic you monitor for alerts. What should you do?
Choose an answer
Tap an option to check your answer.
Correct answer: Use an exception handling block in your Dataflow’s DoFn code to push the messages that failed to be transformed through a side output and to a new Pub/Sub topic. Use Cloud Monitoring to monitor the topic/num_unacked_messages_by_region metric on this new topic..
Why this is the answer
The correct approach is to implement an exception handling block within your Dataflow DoFn. When a message fails processing, catch the exception and use a side output to direct the problematic message to a separate Pub/Sub topic. This pattern, often called a "dead letter queue" or "error topic," allows you to isolate and re-process or alert on failed messages without halting the main pipeline. Monitoring the topic/numunackedmessagesbyregion metric on this new topic will indicate the number of messages awaiting processing in your error queue, signaling issues. Enabling retaining acknowledged messages or creating a subscription snapshot are not designed for real-time error handling and alerting. While Pub/Sub dead-lettering is a valid feature, it's typically configured at the subscription level to catch messages that fail delivery attempts, not necessarily application-level business logic failures within a Dataflow DoFn. Dataflow's side outputs provide more granular control over error routing from within the processing logic itself.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed