node-kafka

a node binding for librdkafka

node-kafka

Node.js binding for librdkafka.

Only connect and produce are implemented so far. consume will be forthcoming (but no immediate need)

Tested with kafka_2.8.0-0.8.0-beta1

From kafka folder

bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 1 --partition 1 --topic test
bin/kafka-list-topic.sh --zookeeper localhost:2181
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
node-gyp configure
node-gyp build
node-gyp rebuild
var kafka = require("./lib/kafka");
 
var producer = new kafka.Producer({
  brokers: "localhost:9092",
  partition: 0,
  topic: "test"
});
 
producer.connect(function() {
  producer.send('message', 0, function(err) {
    ...
  }).on("sent", function(err) {
    ...
  }).on("delivery", function(errlength) {
    ...
  }).on("error", function(err) {
    ...
  });
})
node example.js
node example2.js

See LICENSE, and LICENSE.* for dependencies