Kafka Streams windowing is a powerful feature that enables processing data streams based on time windows.
This example include four pipelines to demonstrate the use of Kafka Streams windowing with the Kafka Streams DSL. Each pipeline demonstrate one of window types.
- Hopping Window
- Tumbling Window
- Sliding Window
- Session Window
- Java 17 or higher
- Maven
- Docker (optional, for running Docker Compose which include Zookeeper and Apache Kafka)
-
Start Kafka and Zookeeper:
docker-compose up
-
Build and Run the Application:
mvn clean package spring-boot:run
After starting the application, first the required topics are created and then some events are produced by producer on the input topic.
Then the four different pipelines in this example's streamWindows package process these events separately. Each pipeline includes different windowing techniques to window the data stream and aggregate the data and finally produce the result to the output topic.
Final messages will also be printed on the screen.