liveBook · Manning

SlidingWindows

As explained in Kafka Streams in Action, Second Edition

SlidingWindows is a Kafka Streams class that defines sliding time windows whose boundaries are based on record timestamps.

SlidingWindows defines fixed-duration Kafka Streams windows whose boundaries follow record timestamps. Each incoming record creates a window ending at its timestamp and looks back for records within the configured maximum time difference. section 9.1.4 section 9.1.5

Key implementation behaviors:

  • Create the window with SlidingWindows.ofTimeDifferenceWithNoGrace(Duration.ofSeconds(30)). section 9.1.4
  • Treat both start and end boundaries as inclusive. section 9.1.4
  • Evaluate when records enter or leave the window, rather than continuously like a hopping window. section 9.1.4

Page-view aggregation

A page-view stream can be grouped by key, windowed with a 30-second sliding difference, aggregated with pageViewAggregator, and written to page-view-sliding-aggregates. section 9.1.4

Figure 9.21 Event timestamps determine the start and end of sliding and session windows.
figure

Use the timestamp-alignment diagram to compare sliding windows with session windows and see how event timestamps determine their boundaries. section 9.1.5

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains API construction, inclusive boundaries, lookback behavior, and evaluation triggers without descending into implementation internals.
Examples
Aggregates keyed page views into a 30-second sliding window and publishes the results to an output topic.
What it assumes
Builds on stream grouping and aggregation APIs, while treating timestamp-driven window behavior as the focus.
What you can do after
Apply it via Kafka Streams to build keyed, timestamp-based sliding aggregations with a configured maximum record difference.
How it connects
Contrasts sliding windows with time, hopping, and session windows through boundary alignment and evaluation behavior.

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.