Created
September 4, 2020 14:53
-
-
Save Odilio/b067008cf3e013e6476880e3ef655d9b to your computer and use it in GitHub Desktop.
This file contains 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 com.boilerplate.kafka.config; | |
import java.util.HashMap; | |
import java.util.Map; | |
import org.apache.kafka.clients.admin.AdminClientConfig; | |
import org.apache.kafka.clients.admin.NewTopic; | |
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; | |
@Configuration | |
public class KafkaTopicConfig { | |
@Value(value = "${kafka.bootstrapAddress}") | |
private String bootstrapAddress; | |
@Value(value = "segundo") | |
private String topicName; | |
@Value(value = "mensagem") | |
private String messageTopicName; | |
@Bean | |
public KafkaAdmin kafkaAdmin() { | |
Map<String, Object> configs = new HashMap<>(); | |
configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress); | |
return new KafkaAdmin(configs); | |
} | |
@Bean | |
public NewTopic topic1() { | |
return new NewTopic(topicName, 1, (short) 1); | |
} | |
@Bean | |
public NewTopic topic2() { | |
return new NewTopic(messageTopicName, 1, (short) 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment