Support Questions

Find answers, ask questions, and share your expertise

How producer and consumer identify the leader in Kafka

avatar
Expert Contributor

Hi,

How producer and consumer identify the leader in Kafka.

Thank you.

4 REPLIES 4

avatar
Super Collaborator

via zookeeper query or bootstraping. the information is stored in zookeeper per topic.

avatar
Expert Contributor

@Harald Berghoff

Thank you for the reply.

How to check this in zookeeper.

avatar
Super Collaborator

@Nilesh within the zookeeper the leader is given at this path:

/brokers/topics/<<topicname>>

at this path a value named 'partitions' is available, providing key value pairs of

<<partition id>> : <<broker id (of leader)>>

To identify the connection parameter for the broker id, check at the path

/brokers/ids/<<broker id>

the attributes "host", "port" and "endpoints", where endpoints is a multivalue and can contain more than one endpoint.

avatar
New Contributor

Since Kafka version 0.9, Producers and consumers fetch all metadata details from Kafka brokers directly and Kafka brokers are in sync with Zookeeper. Each Kafka brokers have information about leader.