Your concern does not make sense. The KafkaAdmin
does not connect by itself. The logic there is like this:
public final boolean initialize() {
Collection<NewTopic> newTopics = this.applicationContext.getBeansOfType(NewTopic.class, false, false).values();
if (newTopics.size() > 0) {
AdminClient adminClient = null;
try {
Map<String, Object> configs2 = new HashMap<>(this.configs);
checkBootstrap(configs2);
adminClient = AdminClient.create(configs2);
}
catch (Exception e) {
if (!this.initializingContext || this.fatalIfBrokerNotAvailable) {
throw new IllegalStateException("Could not create admin", e);
}
else {
LOGGER.error(e, "Could not create admin");
}
}
So, if there is no any NewTopic
beans in the application context the KafkaAdmin
does nothing. If you have some, then what is the reason for that, if not create new topics on the broker before producing/consuming. Therefore KafkaAdmin
logic.