Skip to content

Instantly share code, notes, and snippets.

@j-tim
Created April 10, 2020 12:07
Show Gist options
  • Save j-tim/484b9fa6315c63a9d82f8403b88ffec7 to your computer and use it in GitHub Desktop.
Save j-tim/484b9fa6315c63a9d82f8403b88ffec7 to your computer and use it in GitHub Desktop.
Spring Kafka configuration example to programmatically create a Kafka compact topic
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 compactTopicExample() {
return TopicBuilder.name("my-first-compact-kafka-topic")
.partitions(6)
.replicas(3)
.compact()
.build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment