code
code

Reputation: 5642

How to get Kafka timestamp for a record in Flink?

I have a Flink application that uses the FlinkKafkaConsumer.

I am interested in retrieving the Kafka timestamp for a given record/offset using the KeyedDeserializationSchema. It seems that the topic, partition, offset, and message are available.

How can the timestamp be obtained?

Upvotes: 0

Views: 2629

Answers (1)

Axel Podehl
Axel Podehl

Reputation: 4303

You can simply use ConsumerRecord.timestamp() - the timestamp in milliseconds since beginning of the epoch (midnight Jan 1, 1970 (UTC)). The timestamp type is indicated in timestampType().

Upvotes: 4

Related Questions