'Is it possible to check Kafka broker and the topic which Im sending message is healthy before sending message
I have a batch application which needs to send message to two different Kafka topic on two different clusters. I want to make sure my kafka broker in which my producer app is connecting healthy before sending any messages.
Is it possible to do this kind of check programatically in Spring Boot.
Solution 1:[1]
See KafkaAdmin.describeTopics() API:
/**
* Obtain {@link TopicDescription}s for these topics.
* @param topicNames the topic names.
* @return a map of name:topicDescription.
*/
Map<String, TopicDescription> describeTopics(String... topicNames);
It does connect to the configured cluster and requests the info for topics and their partitions.
See docs for more info: https://docs.spring.io/spring-kafka/docs/current/reference/html/#configuring-topics
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Artem Bilan |
