Class TimestampPolicy<K,V>

java.lang.Object
org.apache.beam.sdk.io.kafka.TimestampPolicy<K,V>
Direct Known Subclasses:
CustomTimestampPolicyWithLimitedDelay, TimestampPolicyFactory.LogAppendTimePolicy, TimestampPolicyFactory.ProcessingTimePolicy, TimestampPolicyFactory.TimestampFnPolicy

public abstract class TimestampPolicy<K,V> extends Object
A timestamp policy to assign event time for messages in a Kafka partition and watermark for it. KafkaIO reader creates one policy using TimestampPolicyFactory for each each of the partitions it reads from. See @TimestampPolicyFactory.LogAppendTimePolicy for example of a policy.
  • Constructor Details

    • TimestampPolicy

      public TimestampPolicy()
  • Method Details

    • getTimestampForRecord

      public abstract Instant getTimestampForRecord(TimestampPolicy.PartitionContext ctx, KafkaRecord<K,V> record)
      Returns record timestamp (aka event time). This is often based on the timestamp of the Kafka record. This is invoked for each record when it is processed in the reader.
    • getWatermark

      public abstract Instant getWatermark(TimestampPolicy.PartitionContext ctx)
      Returns watermark for the partition. It is the timestamp before or at the timestamps of all future records consumed from the partition. See UnboundedSource.UnboundedReader.getWatermark() for more guidance on watermarks. E.g. if the record timestamp is 'LogAppendTime', watermark would be the timestamp of the last record since 'LogAppendTime' monotonically increases within a partition.