Files
spring-cloud-stream-samples/kafka-streams-samples/kafka-streams-word-count
2018-10-11 08:08:38 -04:00
..
2018-03-09 10:47:22 -05:00
2018-10-11 08:08:38 -04:00
2018-03-09 10:47:22 -05:00
2018-03-09 10:47:22 -05:00
2018-03-09 10:47:22 -05:00
2018-03-09 10:47:22 -05:00
2018-08-15 18:34:00 -04:00

== 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 https://github.com/confluentinc/examples/blob/3.2.x/kafka-streams/src/main/java/io/confluent/examples/streams/WordCountLambdaExample.java[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.
This sample uses lambda expressions and thus requires Java 8+.
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`

On another terminal:

`docker exec -it kafka-wordcount /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic 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`