Created
November 3, 2017 15:19
-
-
Save battlecow/efab71d180e593ea0dc6cbcead78b3a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
consumer | |
.on('ready', () => { | |
consumer.subscribe([topic]); | |
consumer.getMetadata({topic: topic}, function (err, metadata) { | |
if (err) { | |
console.error('Error getting metadata'); | |
console.error(err); | |
} else { | |
console.log('Got metadata'); | |
console.log(metadata.topics[1]); | |
var partitions = metadata.topics[1].partitions; | |
partitions.map((p) => { | |
consumer.queryWatermarkOffsets(topic, p.id, (err, offsets) => { | |
console.log(offsets); | |
consumer.seek({topic: topic, partition: p.id, offset: offsets.lowOffset}, 1000, function (err) { | |
if (err) { | |
console.log(err); | |
} | |
}); | |
}); | |
}); | |
setTimeout(function () { | |
consumer.consume(); | |
}, 5000) | |
} | |
}); | |
}) | |
.on('data', (data) => { | |
console.log(data); | |
};); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment