Interface OffsetRetainer
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
FileSystemOffsetRetainer
When configured via DebeziumIO.Read.withOffsetRetainer(OffsetRetainer), the pipeline
behaves as follows:
- On startup,
loadOffset()is called once. If a non-null offset is returned, the Debezium connector resumes from that position; otherwise it starts from the beginning of the change stream. - After each successful
task.commit(),saveOffset(Map)is called with the latest committed offset.
A ready-to-use filesystem-based implementation is provided by FileSystemOffsetRetainer, which supports any Beam-compatible filesystem (local, GCS, S3, etc.)
Implementations must be Serializable because they are embedded inside DebeziumIO.Read, which is a PTransform that gets
serialized and shipped to workers.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the most recently saved offset, ornullif no offset has been saved yet.voidsaveOffset(Map<String, Object> offset) Persists the given offset so it can be recovered after a pipeline restart.
-
Method Details
-
loadOffset
Returns the most recently saved offset, ornullif no offset has been saved yet.A
nullreturn causes the connector to start from the beginning of the change stream. Implementations should handle transient I/O errors gracefully and returnnullon failure rather than propagating an exception. -
saveOffset
Persists the given offset so it can be recovered after a pipeline restart.Called after each successful
task.commit()with the latest committed offset. Implementations should swallow transient errors rather than throwing, so that a failed save does not terminate the pipeline.- Parameters:
offset- The current connector offset, as returned bySourceRecord.sourceOffset().
-