I'm using kafka client v 0.8.0 jar file to send kafka messages as producer. But before sending it I want to check if Kafka is up. How do I do this?
Asked
Active
Viewed 2,913 times
0
-
Possible duplicate of [Is there any way to check if kafka is up and running from kafka-net](http://stackoverflow.com/questions/35807374/is-there-any-way-to-check-if-kafka-is-up-and-running-from-kafka-net) – BSMP May 16 '17 at 15:04
-
refer to my answer here [https://stackoverflow.com/questions/37920923/how-to-check-whether-kafka-server-is-running/49170778#49170778](https://stackoverflow.com/questions/37920923/how-to-check-whether-kafka-server-is-running/49170778#49170778) – Prashanth Reddy Mamidi Mar 08 '18 at 10:31
1 Answers
1
You can check if one of your brokers exist in Zookeeper.
Broker's id is registered in zookeeper(/brokers/ids/[brokerId]) as ephemeral node, which allow other brokers and consumers to detect failures.(Right now the definition of health is fairly naive., if registered in zk /brokers/ids/[brokerId] the broker is healthy, otherwise it is dead).
zookeeper ephemeral node exists as long as the broker's session is active.
You could check if broker is up via ZkUtils.getSortedBrokerList(zkClient), which return all active broker id under /brokers/ids
If you just want to see directly when the broker dies, set the acks property to 1 or all(-1) or/and max.in.flight.requests.per.connection property to 1.