liveBook · Manning

EmitStrategy.onWindowClose

As explained in Kafka Streams in Action, Second Edition

EmitStrategy.onWindowClose is an emit policy that releases a windowed result only when its window closes.

EmitStrategy.onWindowClose() configures a Kafka Streams windowed aggregation to release its result only when the window closes. Add it after windowedBy(...) and before aggregate(...). section 9.3

One-minute tumbling window

iotHeatSensorStream.groupByKey()\n .windowedBy(TimeWindows.ofSizeWithNoGrace(\n Duration.ofMinutes(1)))\n .emitStrategy(EmitStrategy.onWindowClose())\n .aggregate(...);\n\nThis prevents intermediate aggregation results from being emitted while the window remains open. EmitStrategy.onWindowUpdate() is the default when no policy is specified. section 9.3

Figure 9.29 Only a single result is emitted when a window closes.
figure

Shows the output distinction: a closing window produces one final result instead of intermediate results. section 9.3

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains placement, default behavior, and final-result timing, but does not detail internal buffering.
Examples
Uses a one-minute tumbling heat-sensor aggregation configured with emit-on-window-close.
What it assumes
Assumes familiarity with KStream.groupByKey(), windowedBy(), and windowed aggregations.
What you can do after
Configure a windowed aggregation to emit only its final result when the window closes.
How it connects
Connects windowed aggregation with EmitStrategy.onWindowUpdate(), KTable.suppress(), and suppression.

Related concepts

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.