oleksiyk / kafka

Apache Kafka 0.9 client for Node
MIT License
297 stars 85 forks source link

"--from-beginning" consumer equivalent? #246

Open vbhayden opened 5 years ago

vbhayden commented 5 years ago

With the kafka-console-consumer, there's a --from-beginning option for getting all messages across a topic's partitions. I've tried setting the startingOffset:

const consumer = new kafka.GroupConsumer({
    connectionString: KAFKA_URLS,
    startingOffset: kafka.EARLIEST_OFFSET
});

as well as the time in the subscribe call:

consumer.subscribe(KAFKA_XAPI_TOPIC, dataHandler, {
    time: kafka.EARLIEST_OFFSET
})
.then(function (result) {
    //
})

but neither of these seemed to do it. Is there a way to mimic that --from-beginning behavior from the console consumer?