kafka-fork
v0.1.8
Published
A node client for Kafka. My fork with a fix for #5, since I couldn't wait for pull request for too long
Readme
Kafka javascript API
Interact with Kafka, LinkedIn's disk based message queue.
Dependencies
You'll need the libgmp source to compile this package. Under Debian-based systems,
sudo aptitude install libgmp3-devOn a Mac with Homebrew,
brew install gmpGet up and running
1 Install kafka
npm install kafka2 Start zookeeper, kafka server, and a consumer (see http://sna-projects.com/kafka/quickstart.php)
3 Publish and consume some messages!
var kafka = require('kafka')
new kafka.Consumer().connect().subscribeTopic('test').on('message', function(topic, message) {
console.log("Consumed message:", message)
})
var producer = new kafka.Producer().connect().on('connect', function() {
producer.send("hey!")
producer.close()
})API
kafka.Consumer
var consumer = new kafka.Consumer({
// these are the default values
host: 'localhost',
port: 9092,
pollInterval: 2000,
maxSize: 1048576 // 1MB
})
consumer.on('message', function(topic, message) {
console.log(message)
})
consumer.connect(function() {
consumer.subscribeTopic({name: 'test', partition: 0})
})kafka.Producer
var producer = new kafka.Producer({
// these are also the default values
host: 'localhost',
port: 9092,
topic: 'test',
partition: 0
})
producer.connect(function() {
producer.send('message bytes')
})