I am using testcontainers.org with KafkaContainer
.
Currently, I use kafka-topics
to create a topic after starting the container:
kafkaContainer.execInContainer("/bin/sh", "-c", "/usr/bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topicName");
As this takes around 3-5 seconds per topic, I am wondering, if there is a more efficient way to create multiple topics. Or is there a simple switch to autocreate topics on demand?