0

I have a requirement where I need to create and delete Kafka topics programmatically. org.springframework.cloud.stream.binding.BinderAwareChannelResolver . resolveDestination(String channelName) can create a topic, but this is deprecated. Also, there is no way to delete Kafka topic programmatically which I am aware of.

Any suggestions to achieve this are welcome!

Siddu
  • 99
  • 1
  • 8

1 Answers1

1

You can use an AdminClient to create and delete topics. Spring Boot will auto-configure a KafkaAdmin and you can use kafkaAdmin.getConfigurationProperties() to create an admin client with AdminClient.create(props) (or you can just use your own properties).

Gary Russell
  • 166,535
  • 14
  • 146
  • 179