Hello World with a basic Kafka Producer and Consumer

Hello World with a basic Kafka Producer and Consumer. It is assumed that you know Kafka terminology. There is a lot to learn about Kafka, but this starter is as simple as it can get with Zookeeper, Kafka and Java based producer/consumer.

Install Zookeeper and run it in standalone mode. No Zookeeper ensemble for this exercise. Install in this case is just unzip.

Download and install Kafka 1.0. Install in this case is just unzip.

 

And now the Java code to publish and subscribe. I used Eclipse STS and you can run the producer and consumer from the IDE. In the producer console type in a string and hit enter. The text will be published to a test topic. The consumer will continue to run forever and pick up any messages published and print to console. Type in “exit” to stop the publisher (or you can kill it). Consumer can be killed when you are done testing.

 

 


Also published on Medium.

Leave a Reply