From 517f2b4f1b59fc41686be096780e20dd3221c9a7 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Sun, 29 Oct 2023 01:07:02 +0200 Subject: [PATCH] Fixed kafka errors --- .run/MainApplication.run.xml | 20 ------------------- .../configuration/KafkaConfiguration.kt | 20 +++++++++++++++++++ .../src/main/resources/application-prod.yaml | 6 ------ 3 files changed, 20 insertions(+), 26 deletions(-) delete mode 100644 .run/MainApplication.run.xml create mode 100644 module-server/src/main/kotlin/de/twomartens/wahlrecht/configuration/KafkaConfiguration.kt diff --git a/.run/MainApplication.run.xml b/.run/MainApplication.run.xml deleted file mode 100644 index c3644b8..0000000 --- a/.run/MainApplication.run.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - \ No newline at end of file diff --git a/module-server/src/main/kotlin/de/twomartens/wahlrecht/configuration/KafkaConfiguration.kt b/module-server/src/main/kotlin/de/twomartens/wahlrecht/configuration/KafkaConfiguration.kt new file mode 100644 index 0000000..32463be --- /dev/null +++ b/module-server/src/main/kotlin/de/twomartens/wahlrecht/configuration/KafkaConfiguration.kt @@ -0,0 +1,20 @@ +package de.twomartens.wahlrecht.configuration + +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 + +@Configuration +open class KafkaConfiguration { + @Value(value = "\${spring.kafka.bootstrap-servers[0]}") + private val bootstrapServers: List = mutableListOf() + + @Bean + open fun kafkaAdmin(): KafkaAdmin { + val configs: MutableMap = HashMap() + configs[AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG] = bootstrapServers.first() + return KafkaAdmin(configs) + } +} \ No newline at end of file diff --git a/module-server/src/main/resources/application-prod.yaml b/module-server/src/main/resources/application-prod.yaml index 065d55f..cf5bd00 100644 --- a/module-server/src/main/resources/application-prod.yaml +++ b/module-server/src/main/resources/application-prod.yaml @@ -3,11 +3,5 @@ spring: import: - "configserver:${CONFIGSERVER_SCHEME:http}://${CONFIGSERVER_HOST:configserver}:${CONFIGSERVER_PORT:8888}${CONFIGSERVER_PREFIX:/config}" kafka: - producer: - bootstrap-servers: - - ${KAFKA_HOST:kafka}:${KAFKA_PORT:9092} - consumer: - bootstrap-servers: - - ${KAFKA_HOST:kafka}:${KAFKA_PORT:9092} bootstrap-servers: - ${KAFKA_HOST:kafka}:${KAFKA_PORT:9092}