Windowing
Windowing allows you to bucket stateful operations by time, without which your aggregations would endlessly accumulate. A window gives you a snapshot of an aggregate within a given timeframe, and can be set as hopping, tumbling, session, or sliding.
Reference: https://developer.confluent.io/courses/kafka-streams/windowing/
Components
Windowed
windowed stream processing groups records by their keys within a defined time window, allowing operations like joins or aggregations to be performed on data that occurs within the same time range.
# Window Types
- Tumbling: Fixed-size, non-overlapping windows.
- Hopping: Overlapping windows with a fixed size and hop interval.
- Session: Dynamically sized windows based on gaps of inactivity.
- Sliding: Continuously moving time intervals, each time a record enters a defined timespan.
Emit Strategy
Emit on update strategy emits a new, updated window result every time the aggregated state changes due to incoming records.
Emit on close strategy emits the final result only once when the window is considered complete and closed.
Suppressed
Suppressed is an operator that buffers intermediate results and only forwards the final aggregate once the window is complete (or after a defined grace period).
# Suppressed Types
- untilWindowCloses: Buffers all intermediate results and emits only the final result when the window fully closes.
- untilTimeLimit: Buffers intermediate results and emits them either after a specified time limit or when the window closes, whichever comes first.
# BufferConfig Choices
- unbounded: a buffer unconstrained by size (either keys or bytes).
- maxBytes: a size-constrained buffer in terms of the maximum number of bytes it will use.
- maxRecords: a size-constrained buffer in terms of the maximum number of keys it will store.
# Buffer WhenFull Behaviour
- emitEarlyWhenFull: just emit the oldest records when any of its constraints are violated.
- shutDownWhenFull: gracefully shut down the application when any of its constraints are violated