Reference Kafka offical Quickstart, just start ZooKeeper and Kafka services
$ bin/zookeeper-server-start.sh config/zookeeper.properties
$ bin/kafka-server-start.sh config/server.properties
That's it. Don't have to create topic, this demo program will create the topic user-info-topic
automatically.
Since this is a Maven project, so we can use Maven command
mvn exec:java -Dexec.mainClass=cc.unmi.KafkaDemo
to start the Demo application. It's a simple interactive interface
send
: Send messagereceive
: Consume messageexit
: Quit this application
Here is the screenshot