Kafka - How to commit offset after every message using High-Level consumer?

女生的网名这么多〃 提交于 2019-11-28 17:16:27

There are two relevant settings from http://kafka.apache.org/documentation.html#consumerconfigs.

auto.commit.enable

and

auto.commit.interval.ms

If you want to set it such that the consumer commits the offset after each message, that will be difficult since the only setting is after a timer interval, not after each message. You will have to do some rate prediction of the incoming messages and accordingly set the time.

In general, it is not recommended to keep this interval too small because it vastly increases the read/write rates in zookeeper and zookeeper gets slowed down because it's strongly consistent across its quorum.

Yueheng Li

You could first disable auto commit: auto.commit.enable=false

Then commit after fetching the message: consumer.commitOffsets(true)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!