What is this app?

This is an example of a Spring Cloud Stream processor using Kafka Streams support.

The example is based on the word count application from the reference documentation. It uses a single input and a single output. In essence, the application receives text messages from an input topic and computes word occurrence counts in a configurable time window and report that in an output topic. The sample uses a default timewindow of 30 seconds.

Running the app:

Go to the root of the repository.

docker-compose up -d

./mvnw clean package

java -jar target/kafka-streams-word-count-0.0.1-SNAPSHOT.jar

Assuming you are running the dockerized Kafka cluster as above.

Issue the following commands:

docker exec -it kafka-wordcount /opt/kafka/bin/kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic words

Or if you prefer kafkacat:

kafkacat -b localhost:9092 -t words -P

On another terminal:

docker exec -it kafka-wordcount /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic counts

Or if you prefer kafkacat:

kafkacat -b localhost:9092 -t counts

Enter some text in the console producer and watch the output in the console consumer.

Once you are done, stop the Kafka cluster: docker-compose down