1.HighLevelApi
High Level Api是多線程的應(yīng)用程序,以Topic的Partition數(shù)量為中心。消費的規(guī)則如下:
一個partition只能被同一個ConsumersGroup的一個線程所消費.
線程數(shù)小于partition數(shù),某些線程會消費多個partition.
線程數(shù)等于partition數(shù),一個線程正好消費一個線程.
當添加消費者線程時,會觸發(fā)rebalance,partition的分配發(fā)送變化.
同一個partition的offset保證消費有序,不同的partition消費不保證順序.
關(guān)于與ZK的幾個參數(shù)意思解釋
zookeeper.connect: ZK連接。
group.id: Consumer消費ID。
zookeeper.session.timeout.ms: kafka節(jié)點與ZK會話的超時時間。
zookeeper.sync.time.ms: zk的follower與leader的同步時間間隔。
auto.commit.interval.ms: Consumer offset自動提交給Zookeeper的時間。
Note that since the commit frequency is time based instead of # of messages consumed, if an error occurs between updates to ZooKeeper on restart you will get replayed m