The application takes in the favourite colour and username as input and displays the frequency of the favourite colours currently in the stream.
- Kafka
- Java 8
- Maven
- Start the zookeeper and kafka instance using:
bin\windows\zookeeper-server-start.bat config\zookeeper.properties
bin\windows\kafka-server-start.bat config\server.properties
- Create the input topic:
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic colour-count-input
- Create the log-compact topic for KTable:
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic user-keys-and-colours-topic
- Create the output topic:
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic colour-count-output
-
Run the application
-
Start the kafka consumer:
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic colour-count-output --from-beginning --formatter kafka.tools.DefaultMessageFormatter --property print.key=true --property print.value=true --property key.deserializer=org.apache.kafka.common.serialization.StringDeserializer --property value.deserializer=org.apache.kafka.common.serialization.LongDeserializer
- Start the kafka producer with the input-topic:
bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic colour-count-input
Add inputs to the input-topic and monitor the output from the output topic.