Files
spring-cloud-stream-samples/kafka-streams-samples/kafka-streams-word-count
2020-05-23 13:53:21 -04:00
..
2018-03-09 10:47:22 -05:00
2019-10-24 18:12:54 -04:00
2018-03-09 10:47:22 -05:00
2018-03-09 10:47:22 -05:00
2019-03-21 15:21:19 -04:00
2019-03-21 15:21:19 -04:00
2020-05-23 13:53:21 -04:00
2019-10-24 18:12:54 -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.
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`