I think this link should point here, since Confluent removed kafka examples from confluentinc/examples, and put them in confluentinc/kafka-streams-examples.
37 lines
1.7 KiB
Plaintext
37 lines
1.7 KiB
Plaintext
== 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.
|