This is an example of a Spring Cloud Stream processor using Kafka Streams support
The application uses one inputs - one KStream for User changes and groups by the User key into KTable 'allusers' then streams out the changes to 'usertable'
-
Start Kafka and Zookeepr
'cd #kafka_installed_home' 'start bin\windows\zookeeper-server-start.bat config\zookeeper.properties' 'start bin\windows\kafka-server-start.bat config\server.properties'
-
Build the Spring boot application
'mvn clean package'
-
Run the Spring boot application
'java -jar target\kafka-streams-global-table-0.0.1-SNAPSHOT.jar'
-
Create a producer for 'user' topic
'start bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic user'
-
Input the data
Then input the below events one by one to add to the Ktable:
{"id": "1", "name": "paul", "age": 44} {"id": "2", "name": "john", "age": 43} {"id": "3", "name": "virat", "age": 45} {"id": "4", "name": "asha", "age": 100} {"id": "5", "name": "paul", "age": 990}
-
Update data:
{"id": "2", "name": "john", "age": 99} {"id": "3", "name": "virat", "age": 0} {"id": "3", "name": "kohli"} {"id": "3", "age": 33}
Spring boot will also printout the table every 5 seconds on the console.