Kafka Stream 101: Windowing and Event Timestamp

In Kafka Stream 101 course, topic 12 the hands-on exercise performs a time-based window aggregation. In this example, the Record value type (ElectronicOrder) has a time attribute set by the producer to simulate the event time sliding.
But there is no custom TimeStampExtractor defined to extract the timestamp from the Record Value. So, how does the example works? Can someone shed a light to clarify this example?

In the next topic of this course, the instructor explains you need a custom TimeStampExtractor in order to extract the timestamp from the Record’s value…

thanks in advance.

Hi rafaeltuelho,

For this example, Kafka Streams is using a TimestampExtractor, but it’s the default one which pulls the timestamp set when the record is produced.

When we produce the record the example code re-uses that timestamp when creating the ProducerRecord. This isn’t part of the course, I’m just explaining here for some context.

Setting a custom TimestampExtractor is necessary when you want pull the timestamp from the incoming record.

Does this clear things up?



Hey @bbejeck
thanks for pointing that out.

I see it now! When the TopicLoader creates the ProducerRecord you basically re-uses the same timestamp from the EletronicOrder object. Cool!
Now it makes sense :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.