meldestelle/gradle/libs.versions.toml
StefanMoCoAt d87a5a4a93 feat(infra-messaging): Implement fully reactive Kafka producer and consumer
This commit introduces a comprehensive refactoring of the messaging module to establish a fully reactive, non-blocking, and robust infrastructure for Kafka-based communication.

Features & Refinements
Reactive Publisher:

The KafkaEventPublisher has been refactored from a blocking implementation (KafkaTemplate) to a fully non-blocking, reactive one using Spring's ReactiveKafkaProducerTemplate.

The EventPublisher interface now returns reactive types (Mono, Flux) to reflect the asynchronous nature of the operations.

Reactive Consumer:

A new KafkaEventConsumer has been implemented, providing a standardized, reusable, and reactive way for services to consume events.

It encapsulates the complexity of reactor-kafka and exposes a simple receiveEvents<T>(topic) method that returns a Flux<T>.

Architectural Cleanup:

The Spring configuration has been split. The basic ProducerFactory and consumer properties reside in messaging-config, while the reactive-specific ReactiveKafkaProducerTemplate bean is now correctly located in messaging-client.

Testing
Added Kafka Integration Test: A new KafkaIntegrationTest has been created to ensure the reliability of the messaging infrastructure.

The test uses Testcontainers to spin up a real Apache Kafka broker for end-to-end validation.

Project Reactor's StepVerifier is used to test the reactive streams deterministically, avoiding flaky tests.

The test correctly manages the lifecycle of Kafka producers to ensure clean shutdown without hanging threads.

Bug Fixes
Resolved UninitializedPropertyAccessException in tests by making the KafkaConfig test-friendly.

Fixed IllegalStateException related to Testcontainers lifecycle by making the container a static resource.

Corrected compilation errors in tests related to resource cleanup by using the concrete DefaultKafkaProducerFactory type.
2025-08-10 00:02:59 +02:00

220 lines
14 KiB
TOML

# This file is the SINGLE SOURCE OF TRUTH for all project dependencies.
# It allows for centralized version management and ensures consistency.
# Last updated: 2025-07-31
[versions]
# --- Kotlin Ecosystem ---
kotlin = "2.2.0"
kotlinx = "1.9.0"
kotlinxDatetime = "0.7.1"
kotlinLogging = "3.0.5"
# --- Spring Ecosystem ---
springBoot = "3.2.5"
springCloud = "2023.0.1" # NEU: Version für Spring Cloud
springDependencyManagement = "1.1.5"
springdoc = "2.5.0"
# --- Ktor (API Layer & Client) ---
ktor = "3.0.0-beta-2"
# --- Compose UI ---
composeMultiplatform = "1.6.10"
# --- Database & Persistence ---
exposed = "0.51.1"
postgresql = "42.7.3"
hikari = "5.1.0"
h2 = "2.2.224"
flyway = "10.15.2"
redisson = "3.27.2"
lettuce = "6.3.1.RELEASE"
# --- Service Discovery & Monitoring ---
# consulClient = "1.5.3" // wird getauscht mit spring-cloud-starter-consul-discovery
micrometer = "1.12.2"
micrometerTracing = "1.2.5"
zipkin = "3.0.5"
zipkinReporter = "2.16.4"
# --- Authentication ---
auth0Jwt = "4.4.0"
keycloak = "23.0.0"
# --- Testing ---
junitJupiter = "5.10.2"
mockk = "1.13.8"
assertj = "3.24.2"
testcontainers = "1.19.6"
# --- Utilities ---
uuid = "0.8.4"
bignum = "0.3.9"
logback = "1.5.13"
caffeine = "3.1.8"
reactorKafka = "1.3.22"
jackson = "2.17.0"
jakartaAnnotation = "2.1.1"
roomCommonJvm = "2.7.2"
[libraries]
# --- Platform BOMs (Bill of Materials) ---
kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "kotlinx" }
spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "springBoot" }
spring-cloud-dependencies = { module = "org.springframework.cloud:spring-cloud-dependencies", version.ref = "springCloud" } # NEU
# --- Kotlin & Coroutines ---
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" } # Version from BOM
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing" } # Version from BOM
kotlinx-coroutines-reactor = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactor" } # Version from BOM
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test" } # Version from BOM
# --- Ktor Server ---
ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" }
ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm", version.ref = "ktor" }
ktor-server-contentNegotiation = { module = "io.ktor:ktor-server-content-negotiation-jvm", version.ref = "ktor" }
ktor-server-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json-jvm", version.ref = "ktor" }
ktor-server-statusPages = { module = "io.ktor:ktor-server-status-pages-jvm", version.ref = "ktor" }
ktor-server-auth = { module = "io.ktor:ktor-server-auth-jvm", version.ref = "ktor" }
ktor-server-authJwt = { module = "io.ktor:ktor-server-auth-jwt-jvm", version.ref = "ktor" }
ktor-server-cors = { module = "io.ktor:ktor-server-cors-jvm", version.ref = "ktor" }
ktor-server-callLogging = { module = "io.ktor:ktor-server-call-logging-jvm", version.ref = "ktor" }
ktor-server-defaultHeaders = { module = "io.ktor:ktor-server-default-headers-jvm", version.ref = "ktor" }
ktor-server-rateLimit = { module = "io.ktor:ktor-server-rate-limit-jvm", version.ref = "ktor" }
ktor-server-metrics-micrometer = { module = "io.ktor:ktor-server-metrics-micrometer-jvm", version.ref = "ktor" }
ktor-server-openapi = { module = "io.ktor:ktor-server-openapi", version.ref = "ktor" }
ktor-server-swagger = { module = "io.ktor:ktor-server-swagger", version.ref = "ktor" }
ktor-server-tests = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" }
# --- Ktor Client ---
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio-jvm", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-client-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
# --- Spring Boot (Versions from spring-boot-dependencies BOM) ---
spring-boot-starter-web = { module = "org.springframework.boot:spring-boot-starter-web" }
spring-boot-starter-validation = { module = "org.springframework.boot:spring-boot-starter-validation" }
spring-boot-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator" }
spring-boot-starter-data-jpa = { module = "org.springframework.boot:spring-boot-starter-data-jpa" }
spring-boot-starter-data-redis = { module = "org.springframework.boot:spring-boot-starter-data-redis" }
spring-boot-starter-test = { module = "org.springframework.boot:spring-boot-starter-test" }
spring-boot-starter-oauth2-client = { module = "org.springframework.boot:spring-boot-starter-oauth2-client" }
spring-boot-starter-oauth2-resource-server = { module = "org.springframework.boot:spring-boot-starter-oauth2-resource-server" }
spring-boot-starter-security = { module = "org.springframework.boot:spring-boot-starter-security" }
spring-boot-starter-json = { module = "org.springframework.boot:spring-boot-starter-json" }
spring-kafka = { module = "org.springframework.kafka:spring-kafka" }
spring-security-oauth2-jose = { module = "org.springframework.security:spring-security-oauth2-jose" }
spring-web = { module = "org.springframework:spring-web" }
springdoc-openapi-starter-common = { module = "org.springdoc:springdoc-openapi-starter-common", version.ref = "springdoc" }
springdoc-openapi-starter-webmvc-ui = { module = "org.springdoc:springdoc-openapi-starter-webmvc-ui", version.ref = "springdoc" }
# --- Spring Cloud ---
spring-cloud-starter-gateway = { module = "org.springframework.cloud:spring-cloud-starter-gateway" } # NEU
spring-cloud-starter-consul-discovery = { module = "org.springframework.cloud:spring-cloud-starter-consul-discovery" } # NEU
# --- Database & Persistence ---
exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" }
exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "exposed" }
exposed-kotlin-datetime = { module = "org.jetbrains.exposed:exposed-kotlin-datetime", version.ref = "exposed" }
postgresql-driver = { module = "org.postgresql:postgresql", version.ref = "postgresql" }
hikari-cp = { module = "com.zaxxer:HikariCP", version.ref = "hikari" }
h2-driver = { module = "com.h2database:h2", version.ref = "h2" }
flyway-core = { module = "org.flywaydb:flyway-core", version.ref = "flyway" }
flyway-postgresql = { module = "org.flywaydb:flyway-database-postgresql", version.ref = "flyway" }
redisson = { module = "org.redisson:redisson", version.ref = "redisson" }
lettuce-core = { module = "io.lettuce:lettuce-core", version.ref = "lettuce" }
# --- Service Discovery & Monitoring ---
# consul-client = { module = "com.orbitz.consul:consul-client", version.ref = "consulClient" } // wird getauscht mit spring-cloud-starter-consul-discovery
micrometer-prometheus = { module = "io.micrometer:micrometer-registry-prometheus", version.ref = "micrometer" }
micrometer-tracing-bridge-brave = { module = "io.micrometer:micrometer-tracing-bridge-brave", version.ref = "micrometerTracing" } # NEU
zipkin-reporter-brave = { module = "io.zipkin.reporter2:zipkin-reporter-brave", version.ref = "zipkinReporter" }
zipkin-sender-okhttp3 = { module = "io.zipkin.reporter2:zipkin-sender-okhttp3", version.ref = "zipkinReporter" }
zipkin-server = { module = "io.zipkin:zipkin-server", version.ref = "zipkin" }
zipkin-autoconfigure-ui = { module = "io.zipkin:zipkin-autoconfigure-ui", version.ref = "zipkin" }
# --- Authentication ---
auth0-java-jwt = { module = "com.auth0:java-jwt", version.ref = "auth0Jwt" }
keycloak-admin-client = { module = "org.keycloak:keycloak-admin-client", version.ref = "keycloak" }
# --- Utilities ---
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
bignum = { module = "com.ionspin.kotlin:bignum", version.ref = "bignum" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
kotlin-logging-jvm = { module = "io.github.microutils:kotlin-logging-jvm", version.ref = "kotlinLogging" }
caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" }
reactor-kafka = { module = "io.projectreactor.kafka:reactor-kafka", version.ref = "reactorKafka" }
jackson-module-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
jackson-datatype-jsr310 = { module = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", version.ref = "jackson" }
jakarta-annotation-api = { module = "jakarta.annotation:jakarta.annotation-api", version.ref = "jakartaAnnotation" }
# --- Compose UI ---
compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "composeMultiplatform" }
compose-foundation = { module = "org.jetbrains.compose.foundation:foundation", version.ref = "composeMultiplatform" }
compose-material3 = { module = "org.jetbrains.compose.material3:material3", version.ref = "composeMultiplatform" }
compose-ui = { module = "org.jetbrains.compose.ui:ui", version.ref = "composeMultiplatform" }
compose-components-resources = { module = "org.jetbrains.compose.components:components-resources", version.ref = "composeMultiplatform" }
compose-materialIconsExtended = { module = "org.jetbrains.compose.material:material-icons-extended", version.ref = "composeMultiplatform" }
compose-html-core = { module = "org.jetbrains.compose.html:html-core", version.ref = "composeMultiplatform" }
compose-desktop-currentOs = { module = "org.jetbrains.compose.desktop:desktop", version.ref = "composeMultiplatform" }
# --- Testing ---
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junitJupiter" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiter" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junitJupiter" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } # Version from BOM
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
testcontainers-core = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" }
testcontainers-junit-jupiter = { module = "org.testcontainers:junit-jupiter", version.ref = "testcontainers" }
testcontainers-postgresql = { module = "org.testcontainers:postgresql", version.ref = "testcontainers" }
testcontainers-kafka = { module = "org.testcontainers:kafka", version.ref = "testcontainers" }
reactor-test = { module = "io.projectreactor:reactor-test" } # Version wird von der Spring BOM verwaltet
room-common-jvm = { group = "androidx.room", name = "room-common-jvm", version.ref = "roomCommonJvm" }
[bundles]
# OPTIMIERUNG: Bündelt gängige Abhängigkeitsgruppen.
# Dies vereinfacht die build.gradle.kts-Dateien der Module erheblich.
ktor-server-essentials = [
"ktor-server-core", "ktor-server-netty", "ktor-server-contentNegotiation",
"ktor-server-serialization-kotlinx-json", "ktor-server-statusPages", "ktor-server-callLogging"
]
ktor-client-essentials = ["ktor-client-core", "ktor-client-cio", "ktor-client-contentNegotiation", "ktor-client-serialization-kotlinx-json"]
exposed = ["exposed-core", "exposed-dao", "exposed-jdbc", "exposed-kotlin-datetime"]
flyway = ["flyway-core", "flyway-postgresql"]
spring-boot-essentials = ["spring-boot-starter-web", "spring-boot-starter-validation", "spring-boot-starter-actuator"]
redis-cache = ["spring-boot-starter-data-redis", "lettuce-core", "jackson-module-kotlin", "jackson-datatype-jsr310"]
kafka-config = ["spring-kafka", "spring-boot-starter-json", "jackson-module-kotlin", "jackson-datatype-jsr310"]
testing-jvm = ["junit-jupiter-api", "junit-jupiter-engine", "mockk", "assertj-core", "kotlinx-coroutines-test"]
testcontainers = ["testcontainers-core", "testcontainers-junit-jupiter", "testcontainers-postgresql"]
# NEU: Bündelt alle Abhängigkeiten, die ein Service für Metriken und Tracing benötigt.
monitoring-client = [
"spring-boot-starter-actuator",
"micrometer-prometheus",
"micrometer-tracing-bridge-brave",
"zipkin-reporter-brave",
"zipkin-sender-okhttp3"
]
# NEU: Bündelt die Kernabhängigkeiten für das Spring Cloud Gateway.
spring-cloud-gateway = ["spring-cloud-starter-gateway", "spring-cloud-starter-consul-discovery"]
[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-jpa = { id = "org.jetbrains.kotlin.plugin.jpa", version.ref = "kotlin" }
kotlin-spring = { id = "org.jetbrains.kotlin.plugin.spring", version.ref = "kotlin" }
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
spring-boot = { id = "org.springframework.boot", version.ref = "springBoot" }
spring-dependencyManagement = { id = "io.spring.dependency-management", version.ref = "springDependencyManagement" }