Last active
August 17, 2020 19:20
-
-
Save j-tim/a882e345e305475d83df082a392eb0be to your computer and use it in GitHub Desktop.
Spring Kafka configuration example to programmatically create a Kafka topic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.stockgeeks.kafka.config; | |
import org.apache.kafka.clients.admin.NewTopic; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.kafka.config.TopicBuilder; | |
@Configuration | |
public class KafkaTopicConfiguration { | |
@Bean | |
public NewTopic topicExample() { | |
return TopicBuilder.name("my-first-kafka-topic") | |
.partitions(6) | |
.replicas(3) | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment