Hi Janice Chi
Is
startingOffsetsByTimestamp
the right way to align with a DB2 snapshot timestamp
Yes, that’s a standard and practical approach. It uses Kafka’s offsetsForTimes
under the hood to find the earliest offset at or after a given timestamp. As long as the DB2 snapshot timestamp aligns with the commit time of records, this method works well to mark your starting point.
Can the
jrn_timestamp
from the CDC payload be used as the commit anchor
Absolutely using jrn_timestamp
is a good way to drive commit-aware logic, especially if you need to reconcile or filter out-of-order records. Just make sure the field is consistently populated and reflects DB2 commit time.
Any best practices for freezing
end_offset
for bounded catch-up batches
A common pattern is to capture the latest offsets (or wall-clock time) before starting the batch, then filter records using jrn_timestamp
to stay within that window. You can store this timestamp as a metadata marker and use it to prevent overlap between batches.
Should reconciliation happen against DB2 or just based on the CDC payload
Typically, reconciliation is done only against the CDC payload, especially in streaming pipelines. It avoids putting extra load on DB2 and keeps your pipeline loosely coupled. As long as jrn_timestamp
is reliable, that should be sufficient.
Any known limitations in timestamp-to-offset lookups across many partitions
Yes, there are a few things to be aware of:
-
offsetsForTimes
performs one call per partition, so it can be slow across a large number of partitions. - If a partition has no messages after the given timestamp, the result will be
null
, which your logic must handle. - Retention policies can cause older offsets to be unavailable (leading to
OffsetOutOfRange
errors). - Kafka timestamps may not match your
jrn_timestamp
field, depending on how they are assigned.
You can find more details in the official Microsoft docs here: https://learn.microsoft.com/en-us/azure/databricks/connect/streaming/kafka#startingoffsetsbytimestamp
I hope this information helps. Please do let us know if you have any further queries.
Kindly consider upvoting the comment if the information provided is helpful. This can assist other community members in resolving similar issues.