Created
April 10, 2020 12:11
-
-
Save j-tim/20e5b5c1340e737bfc4fb82a93943829 to your computer and use it in GitHub Desktop.
Non Spring Boot Kafka topic configuration.
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.AdminClientConfig; | |
| import org.springframework.beans.factory.annotation.Value; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Configuration; | |
| import org.springframework.kafka.core.KafkaAdmin; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| @Configuration | |
| public class KafkaTopicConfiguration { | |
| @Value(value = "${kafka.bootstrapServers:localhost:9092}") | |
| private String bootstrapServers; | |
| @Bean | |
| public KafkaAdmin kafkaAdmin() { | |
| Map<String, Object> configs = new HashMap<>(); | |
| // Depending on you Kafka Cluster setup you need to configure | |
| // additional properties! | |
| configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); | |
| return new KafkaAdmin(configs); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment