KafkaAdmin - see Configuring Topics
ProducerFactory - see Sending Messages
ConsumerFactory - see Receiving Messages
Starting with version 2.5, each of these extends KafkaResourceFactory. This allows changing the bootstrap servers at runtime by adding a Supplier
For convenience, the framework also provides an ABSwitchCluster which supports two sets of bootstrap servers; one of which is active at any time. Configure the ABSwitchCluster and add it to the producer and consumer factories, and the KafkaAdmin, by calling setBootstrapServersSupplier(). When you want to switch, call primary() or secondary() and call reset() on the producer factory to establish new connection(s); for consumers, stop() and start() all listener containers. When using @KafkaListener s, stop() and start() the KafkaListenerEndpointRegistry bean.
https://www.javaguides.net/2022/12/spring-boot-apache-kafka-tutorial-16.html