How to use Kafka in NodeJs

Create a folder KafkaNodeJs Run npm init command from inside the folder and answer the few question like author, license, etc… once done, package.json file will be created in our folder. create a new file index.js we will use kafkajs library. open command prompt and run npm install kafkajs open index.js file and type below program const { Kafka, PartitionAssigners: { roundRobin } } = require("kafkajs"); const kafka = new Kafka({ clientId: 'my-app', brokers: ["localhost:9092"] }); const consumer = kafka....

December 24, 2019 · 1 min · 127 words · M.Kumaran