Google Cloud Professional Data Engineer — Question 199

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?

Answer options

Correct answer: B

Explanation

The correct answer is B because it allows you to handle exceptions directly within your DoFn, sending failed messages to a separate Pub/Sub topic for monitoring. Option A is incorrect as it only retains acknowledged messages without addressing failures. Option C, while it mentions dead lettering, does not utilize the exception handling in the DoFn, and option D is not relevant to handling message failures.