How to set consumer option "auto.offset.reset" ?
nobusue opened this issue · 8 comments
I'd like to consume from latest message when I don't have committed offset (ex: new consumer group).
At v0.3.2, HighLevelConsumer consumes from oldest message, but it isn't expected.
You can set fromOffset true and give the offset you wish to consume in payload, example:
consumer = new HighLevelConsumer(
client,
[
{ topic: 't', offset: 1000 }
],
{ fromOffset: true }
);
Thanks haio, but it doesn't match my needs.
I just intend to start consume latest message for "fresh consumer" (= there is no committed offset entry in zookeeper). In other language like Java, Kafka client API supports to set option map, like "auto.offset.reset=latest".
Is there any way to set Kafka client API option map directly?
This feature is not supported at the moment.
I'll have a PR coming for picking up from the latest offset.
@CharlesWall any option like auto.offset.reset=latest , sometime soon for 0.8.* version of kafka for node client.
I haven't looked at any of this stuff since May. I learned how this module worked to write the fix I needed. @shubSK You should consider doing the same.
The solution is to use ConsumerGroup
which supports both earliest
and latest
. I don't think it's worth updating the HLC since it has been deprecated by Kafka project.