I'm receiving DStream from Kafka and I want to group all messages in some sliding window by keys. 

The point is that this window need to be based on timestamps provided in each message (separate field):

```
Message structure
--------------------------
key1, ..., ..., 1557678233
key1, ..., ..., 1557678234 
key2, ..., ..., 1557678235 

```

So, I want to consider messages where for each key `timestamp of the first message` - `timestamp of the last message` <= 5 minutes

As I can see from this [question](https://stackoverflow.com/questions/28571416/spark-window-function-with-synthetic-timestamp), that's not feasible since Spark counts only system time for events. The guy over there suggests using `updateStateByKey`, which is not very clear for me...

Maybe we could achieve this using another approach?

What about including timestamp's differences in `combiners` for `combineByKey` function with further summation & filtering by durations threshold?

Please add your thoughts on that, or share your solution if you had a chance to face the same problem...

Thanks!