我有一个批处理应用程序,需要在两个不同的集群上向两个不同的Kafka主题发送消息。我想确保我的kafka代理,我的生产者应用程序在发送任何消息之前连接健康。
是否可以在Spring Boot中以编程方式进行这种检查。
请参见KafkaAdmin. callbeTopics()
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);
它确实连接到配置的集群并请求主题及其分区的信息。
有关详细信息,请参阅文档:https://docs.spring.io/spring-kafka/docs/current/reference/html/#configuring-topics