I have a pipeline with quite a few steps (just above 15). I want to report failures everytime a DoFn
fails. I started implementing it through TupleTags
with code such as :
try {
... do stuff ...
c.output(successTag, ...);
} catch (Exception e) {
c.output(failureTag, new Failure(...));
}
But since my pipeline contains a lot of steps, this make the pipeline definition code quite hard to read / maintain.
Is there a more global way to achieve it ? Something like raising a custom exception which is handled globally at the pipeline level ?
What you are doing is the correct approach to catch errors and output them differently. You will need this on each step though. You could use a java pattern to reuse it if you prefer. Create a base class for all your ParDos and in processElement add the exception handling code. Then implement your processElement in a separate function (i.e. processElementImpl) which you call in processElement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With