Permalink
Browse files

updated samples

  • Loading branch information...
pelger committed May 30, 2014
1 parent 5eac8da commit 17c20da69e1e63bb6315114bc2a7e54e21e08471
Showing with 27 additions and 77 deletions.
  1. +2 −2 README.md
  2. +1 −1 package.json
  3. +1 −1 samples/fetch.js
  4. +23 −0 samples/fetchFromStart.js
  5. +0 −38 samples/produceConcurrent.js
  6. +0 −35 samples/produceSerial.js
View
@@ -11,7 +11,7 @@ Kafkaesque will uses API as opposed to reading meta commit information from zook
Kafkaesque has an implementation for the offset fetch/commit API, this is not funcitonal in the .8.x Kafka releases. Expected in .9.x release.
## Prerequisites
-You will need to install Apache Kafka from source. Pull the main branch from [https://github.com/apache/kafka](https://github.com/apache/kafka) and follow the instructions in the README.
+You will need to install Apache Kafka 0.8.x or greater.
## Installation
@@ -94,7 +94,7 @@ node produce.js
Will post two messages to the testing topic
````
-node consume.js
+node fetch.js
````
Will consume messages from the testing topic. Note that the consume stores its position in the kafka commit log using the commit/offset/fetch API.
View
@@ -8,7 +8,7 @@
"0.8",
"0.9"
],
- "version": "0.0.9",
+ "version": "0.0.10",
"license": "MIT",
"author": "Peter Elger (http://www.nearform.com/)",
"contributors": [
View
@@ -1,11 +1,11 @@
'use strict';
+
var kafkaesque = require('../lib/kafkaesque')({brokers: [{host: 'localhost', port: 9092}],
clientId: 'fish',
group: 'cheese',
maxBytes: 2000000});
kafkaesque.tearUp(function() {
- //kafkaesque.poll({topic: 'testing123', partition: 0, offset: 40}, function(err, kafka) {
kafkaesque.poll({topic: 'testing123', partition: 0}, function(err, kafka) {
console.log(err);
View
@@ -0,0 +1,23 @@
+'use strict';
+
+var kafkaesque = require('../lib/kafkaesque')({brokers: [{host: 'localhost', port: 9092}],
+ clientId: 'fish',
+ group: 'cheese',
+ maxBytes: 2000000});
+kafkaesque.tearUp(function() {
+ kafkaesque.poll({topic: 'testing123', partition: 0, offset: 0}, function(err, kafka) {
+ console.log(err);
+
+ kafka.on('message', function(offset, message, commit) {
+ console.log(JSON.stringify(message));
+ commit();
+ });
+
+ kafka.on('error', function(error) {
+ console.log(JSON.stringify(error));
+ });
+
+ });
+});
+
+
@@ -1,38 +0,0 @@
-'use strict';
-
-var kafkaesque = require('../lib/kafkaesque')({brokers: [{host: 'localhost', port: 9092}],
- clientId: 'fish',
- group: 'wtf',
- maxBytes: 2000000});
-kafkaesque.tearUp(function() {
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(err);
- console.log(response);
- });
-});
-
-
View
@@ -1,35 +0,0 @@
-'use strict';
-
-var kafkaesque = require('../lib/kafkaesque')({brokers: [{host: 'localhost', port: 9092}],
- clientId: 'fish',
- group: 'wtf',
- maxBytes: 2000000});
-kafkaesque.tearUp(function() {
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.produce({topic: 'testing123', partition: 0}, ['wotcher mush', 'orwlight geezer'], function(err, response) {
- console.log(response);
- kafkaesque.tearDown();
- });
- });
- });
- });
- });
- });
- });
- });
-});
-
-

0 comments on commit 17c20da

Please sign in to comment.