Files
spring-cloud-stream-samples/kafka-streams-samples/kafka-streams-branching
2020-10-16 19:52:27 -04:00
..
2018-03-09 10:47:22 -05:00
2019-10-28 16:20:36 -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
2019-11-08 16:24:08 -05:00

== What is this app?

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

The example is based on the word count application from the https://github.com/confluentinc/kafka-streams-examples/blob/5.3.0-post/src/main/java/io/confluent/examples/streams/WordCountLambdaExample.java[reference documentation].
It uses a single input and 3 output destinations.
In essence, the application receives text messages from an input topic, filter them by language (English, French, Spanish and ignoring the rest), and computes word occurrence counts in a configurable time window and report that in the output topics.

=== Running the app:

Go to the root of the repository and do:

`docker-compose up -d`

`./mvnw clean package`

`java -jar target/kafka-streams-branching-0.0.1-SNAPSHOT.jar`

Issue the following commands:

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

On another terminal:

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

On another terminal:

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

On another terminal:

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

Enter text ("English", "French", "Spanish" - case doesn't matter) in the console producer and watch the output in the respective console consumer.
The word "english" goes to topic english-counts, "french" goes to topic french-counts and "spanish" goes to spanish-counts.