java - How does Kafka store offsets for each topic? -


while polling kafka, have subscribed multiple topics using subscribe() function. now, want set offset want read each topic, without resubscribing after every seek() , poll() topic. calling seek() iteratively on each of topic names, before polling data achieve result? how offsets stored in kafka?

i have 1 partition per topic , 1 consumer read topics.

how kafka store offset each topic ?

kafka has moved offset storage zookeeper kafka brokers. reason below:

zookeeper not way service high-write load such offset updates because zookeeper routes each write though every node , hence has no ability partition or otherwise scale writes. have known this, chose implementation kind of "marriage of convenience" since depended on zk.

kafka store offset commits in topic, when consumer commit offset, kafka publish commit offset message "commit-log" topic , keep in-memory structure mapped group/topic/partition latest offset fast retrieval. more design infomation found in this.

now, want set offset want read each topic, without resubscribing after every seek() , poll() topic.

there new feature kafka admin tools reset offset.

kafka-consumer-group.sh --bootstrap-server 127.0.0.1:9092 --group your-consumer-group --reset-offsets --to-offset 1 --all-topics --execute

more options can refer https://cwiki.apache.org/confluence/display/kafka/kip-122%3a+add+reset+consumer+group+offsets+tooling


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -