Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 1.37 KB

README.md

File metadata and controls

50 lines (38 loc) · 1.37 KB

Prozess

Build Status

Prozess is a Kafka library for node.js

Kafka is a persistent, efficient, distributed publish/subscribe messaging system.

There are two low-level clients: The Producer and the Consumer:

##Producer example:

var Producer = require('Prozess').Producer;

var producer = new Producer('social', {host : 'localhost'});
producer.connect(function(err){
  if (err) {  throw err; }
  console.log("producing for ", producer.topic);
  setInterval(function(){
    var message = { "thisisa" :  "test " + new Date()};
    producer.send(JSON.stringify(message));
  }, 1000);
});

##Consumer example:

var Consumer = require('Prozess').Consumer;

var options = {host : 'localhost', topic : 'social', partition : 0, offset : 0};
var consumer = new Consumer(options);
consumer.connect(function(){
  console.log("connected!!");
  setInterval(function(){
    console.log("===================================================================");
    console.log(new Date());
    console.log("consuming: " + consumer.topic);
    consumer.consume(function(err, messages){
      console.log(err, messages);
    });
  }, 7000);
});

You have to be running Zookeeper and Kafka for this to work, of course.