Search code examples
javaapache-kafka-streamswindowing

Changing the duration of a Kafka Stream SessionWindows iteratively


Suppose I have a Kafka Stream with a SessioWindowing such as:

windowedBy(SessionWindows.with(inactivity_time).until(aWeek))

Would it be possible to change the inactivity time gap of the window iteratively depending on the arrival of the following records?

Such as if I have initially defined my inactivity_time=360000 with the first record, would it be possible to modify this value if a second record of the same key doesn't arrive after inactivity_time/2?


Solution

  • This is not possible with built-in functionality, unfortunately.

    Doing so would require you to implement this custom functionality yourself, e.g. with the Processor API of Kafka Streams (the resulting Processors/Transformers you could then plug into the DSL of Kafka Streams).