Skip to content
Kafka Is FunProgress

SpringSpring Kafka Advanced

What is the KafkaAdmin bean and how do you use it to manage topics?

Reference answer

KafkaAdmin is a Spring wrapper around Kafka's AdminClient. It's autoconfigured by Spring Boot. Declare NewTopic beans and KafkaAdmin will create them at startup: @Bean NewTopic ordersTopic() { return TopicBuilder.name('orders').partitions(6).replicas(3).build(); }. KafkaAdmin checks if topics exist and creates missing ones. It does NOT delete or modify existing topics by default. Use AdminClient directly for advanced operations (reassignment, config changes, deletion). The KafkaAdmin bean also connects to the cluster for health checks.

Expected key concepts: KafkaAdmin, AdminClient, NewTopic, TopicBuilder, autoconfigured, startup, create, health checks, partitions, replicas