ErrorT
- The type of the error object. This will usually be a BadRecord
, but can
be any typeOutputT
- The return type of the sink PTransform.
Usage of Error Handlers:
Simple usage with one DLQ
PCollection<?> records = ...;
try (BadRecordErrorHandler<T> errorHandler = pipeline.registerBadRecordErrorHandler(SomeSink.write())) {
PCollection<?> results = records.apply(SomeIO.write().withErrorHandler(errorHandler));
}
results.apply(SomeOtherTransform);
Usage with multiple DLQ stages
PCollection<?> records = ...;
try (BadRecordErrorHandler<T> errorHandler = pipeline.registerBadRecordErrorHandler(SomeSink.write())) {
PCollection<?> results = records.apply(SomeIO.write().withErrorHandler(errorHandler))
.apply(OtherTransform.builder().withErrorHandler(errorHandler));
}
results.apply(SomeOtherTransform);
This is marked as serializable despite never being needed on the runner, to enable it to be a
parameter of an Autovalue configured PTransform.public interface ErrorHandler<ErrorT,OutputT extends POutput>
extends java.lang.AutoCloseable, java.io.Serializable
Modifier and Type | Interface and Description |
---|---|
static class |
ErrorHandler.BadRecordErrorHandler<OutputT extends POutput> |
static class |
ErrorHandler.DefaultErrorHandler<ErrorT,OutputT extends POutput>
A default, placeholder error handler that exists to allow usage of .addErrorCollection()
without effects.
|
static class |
ErrorHandler.PTransformErrorHandler<ErrorT,OutputT extends POutput> |
Modifier and Type | Method and Description |
---|---|
void |
addErrorCollection(PCollection<ErrorT> errorCollection) |
OutputT |
getOutput() |
boolean |
isClosed() |
void addErrorCollection(PCollection<ErrorT> errorCollection)
boolean isClosed()
OutputT getOutput()