Important Notice: CloudKarafka is shutting down. Read all about it in our End of Life Announcement

Node.js

The best Kafka library for node.js right now is Blizzard's node-rdkafka.

First thing that you have to do is connect to the Kafka server. You can get all the connection variables you need from the provider you used to create the CloudKarafka instance.

You can install the node-rdkafka module by using npm: npm install node - rdkafka

const consumer = new Kafka.KafkaConsumer(kafkaConf, {
  "auto.offset.reset": "beginning"
});
consumer.on("ready", function(arg) {
  consumer.subscribe(topics);
  consumer.consume();
});
consumer.on("data", function(m) {
  console.log(m.value.toString());
});

consumer.connect();

The code example can be found here: https://github.com/CloudKarafka/nodejs-kafka-example