Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bab1892673 | ||
|
|
247fe83caa | ||
|
|
5fe6165373 | ||
|
|
64a8f17e6e |
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package de.twomartens.wahlrecht.configuration
|
||||||
|
|
||||||
|
import org.apache.kafka.clients.admin.AdminClientConfig
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.context.annotation.Profile
|
||||||
|
import org.springframework.kafka.core.KafkaAdmin
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
open class KafkaConfiguration {
|
||||||
|
@Bean
|
||||||
|
@Profile("prod")
|
||||||
|
open fun kafkaProd() = KafkaAdmin(mapOf(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to "kafka:9092"))
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Profile("dev")
|
||||||
|
open fun kafkaDev() = KafkaAdmin(mapOf(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG to "localhost:9092"))
|
||||||
|
}
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
package de.twomartens.wahlrecht.service
|
|
||||||
|
|
||||||
import mu.KotlinLogging
|
|
||||||
import org.apache.logging.log4j.message.StringMapMessage
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier
|
|
||||||
import org.springframework.cloud.context.refresh.ContextRefresher
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled
|
|
||||||
import org.springframework.stereotype.Service
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
/**
|
|
||||||
* automatically reloads application*.yaml. reload can also be triggered manually by doing a post
|
|
||||||
* request on http://localhost:12001/actuator/refresh
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
class PropertyReloadService(@Qualifier("configDataContextRefresher") private val contextRefresher: ContextRefresher) {
|
|
||||||
@Scheduled(
|
|
||||||
fixedDelay = REFRESH_SECONDS.toLong(),
|
|
||||||
initialDelay = REFRESH_SECONDS.toLong(),
|
|
||||||
timeUnit = TimeUnit.SECONDS
|
|
||||||
)
|
|
||||||
fun refresh() {
|
|
||||||
val properties = contextRefresher.refresh()
|
|
||||||
if (properties.isNotEmpty()) {
|
|
||||||
log.info(
|
|
||||||
StringMapMessage()
|
|
||||||
.with(PARAM_MESSAGE, "properties changed")
|
|
||||||
.with(PARAM_PROPERTIES, properties.joinToString("\n"))
|
|
||||||
.asString()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val REFRESH_SECONDS = 60
|
|
||||||
const val PARAM_MESSAGE = "message"
|
|
||||||
const val PARAM_PROPERTIES = "labels.properties"
|
|
||||||
|
|
||||||
private val log = KotlinLogging.logger {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
de.twomartens.wahlrecht:
|
de.twomartens.wahlrecht:
|
||||||
defaultTimeZone: Europe/Berlin
|
defaultTimeZone: Europe/Berlin
|
||||||
greeting: "Hello %s"
|
greeting: "Hello %s, on millenium"
|
||||||
statusprobe:
|
statusprobe:
|
||||||
scheduleDuration: 60
|
scheduleDuration: 60
|
||||||
maxKafkaFailureDuration: 5
|
maxKafkaFailureDuration: 5
|
||||||
|
|||||||
Reference in New Issue
Block a user