Skip to content

Instantly share code, notes, and snippets.

@battlecow
Created November 3, 2017 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save battlecow/efab71d180e593ea0dc6cbcead78b3a7 to your computer and use it in GitHub Desktop.
Save battlecow/efab71d180e593ea0dc6cbcead78b3a7 to your computer and use it in GitHub Desktop.
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