Created
April 10, 2020 12:08
-
-
Save j-tim/6be02ffa342d0e36a99bd97022ddcf99 to your computer and use it in GitHub Desktop.
Spring Kafka configuration example of passing specific Kafka topic configuration properties (in this case to configure compression)
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
import org.apache.kafka.clients.admin.NewTopic; | |
import org.apache.kafka.common.config.TopicConfig; | |
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 topicWithCompressionExample() { | |
return TopicBuilder.name("kafka-topic-with-compression") | |
.partitions(6) | |
.replicas(3) | |
.config(TopicConfig.COMPRESSION_TYPE_CONFIG, "zstd") | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment