TimestampExtractor
@Evolving public class UsePreviousTimeOnInvalidTimestamp extends java.lang.Object
Here, "embedded metadata" refers to the fact that compatible Kafka producer clients automatically and transparently embed such timestamps into message metadata they send to Kafka, which can then be retrieved via this timestamp extractor.
If the embedded metadata timestamp represents CreateTime (cf. Kafka broker setting
message.timestamp.type
and Kafka topic setting log.message.timestamp.type
),
this extractor effectively provides event-time semantics.
If LogAppendTime is used as broker/topic setting to define the embedded metadata timestamps,
using this extractor effectively provides ingestion-time semantics.
If you need processing-time semantics, use WallclockTimestampExtractor
.
Constructor | Description |
---|---|
UsePreviousTimeOnInvalidTimestamp() |
Modifier and Type | Method | Description |
---|---|---|
long |
extract(ConsumerRecord<java.lang.Object,java.lang.Object> record,
long previousTimestamp) |
Extracts the embedded metadata timestamp from the given
ConsumerRecord . |
long |
onInvalidTimestamp(ConsumerRecord<java.lang.Object,java.lang.Object> record,
long recordTimestamp,
long previousTimestamp) |
Returns the current stream-time as new timestamp for the record.
|
public long onInvalidTimestamp(ConsumerRecord<java.lang.Object,java.lang.Object> record, long recordTimestamp, long previousTimestamp) throws StreamsException
record
- a data recordrecordTimestamp
- the timestamp extractor from the recordpreviousTimestamp
- the latest extracted valid timestamp of the current record's partition˙ (could be -1 if unknown)StreamsException
- if latest extracted valid timestamp is unknownpublic long extract(ConsumerRecord<java.lang.Object,java.lang.Object> record, long previousTimestamp)
ConsumerRecord
.extract
in interface TimestampExtractor
record
- a data recordpreviousTimestamp
- the latest extracted valid timestamp of the current record's partition˙ (could be -1 if unknown)ConsumerRecord