Skip to content

Kafka streams stateful aggregation example using state stores and Processor API.

Notifications You must be signed in to change notification settings

aditya232/kafka-streams-stateful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

kafka-streams-stateful example

This example demonstrates aggregation in Kafka Streams with two different approaches, one based on DSL operators like groupByKey and reduce, and another using Kafka Streams Processor API and state stores.

Dependencies

  • JAVA 8,Maven and Kafka should be installed for running this project.

To Run:

  • Create input Kafka topic user-activity from Kafka root directory:
    bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 4 --topic user-activity
  • Run mvn clean compile assembly:single. A jar named kafka-streams-stateful-1.0-SNAPSHOT-jar-with-dependencies.jar will be created in target directory.
  • A data generation script is present in the TestDataGenerator class with which you can push Kafka messages to the input Kafka topic:
    java -cp target/kafka-streams-stateful-1.0-SNAPSHOT-jar-with-dependencies.jar org.streams.demo.TestDataGenerator {{number_of_messages}}
  • To Run the Kafka Streams Application:
    java -cp target/kafka-streams-stateful-1.0-SNAPSHOT-jar-with-dependencies.jar org.streams.demo.Main

About

Kafka streams stateful aggregation example using state stores and Processor API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages