Alternate approach to Kstreams using flink. The temperature status is calculated using predefined values. The key and value of the kafka is consumed and produced using custom serde.
To run the application, Build the maven project
mvn clean install
Submit the application to the flink cluster. The docker file with embedded flink cluster and kafka broker is provided in resources/docker. It can be started via
docker-compose up -d
Create dummy data by Datagen or by console producer as below
kafka-console-producer.bat --bootstrap-server localhost:9092 --topic flink_source --property "parse.key=true" --property "key.separator=|"
{"serial" : "1"}|{"serial":"1","owner":"appu","temp":"25","location":"earth"} //normal
{"serial" : "1"}|{"serial":"1","owner":"appu","temp":"66","location":"earth"} //hot
{"serial" : "1"}|{"serial":"1","owner":"appu","temp":"-4","location":"earth"} //cold
{"serial" : "1"}|{"serial":"1","owner":"appu","temp":"99","location":"earth"} //invalid
The output can be observed by consuming the destination topic
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic flink_destination --property print.key=true