feat: Health-Check-Ports und Service-URLs konsolidiert, Consul-Best-Practices umgesetzt

Signed-off-by: StefanMoCoAt <stefan.mo.co@gmail.com>
This commit is contained in:
2026-04-16 21:26:54 +02:00
parent dd76ad6d14
commit 26b3b193ca
19 changed files with 130 additions and 43 deletions
@@ -1,6 +1,5 @@
package at.mocode.infrastructure.gateway.config
import org.springframework.beans.factory.annotation.Value
import org.springframework.cloud.gateway.route.RouteLocator
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder
import org.springframework.cloud.gateway.route.builder.filters
@@ -9,15 +8,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class GatewayConfig(
@Value("\${ping.service.url:http://localhost:8082}") private val pingServiceUrl: String,
@Value("\${masterdata.service.url:http://localhost:8086}") private val masterdataServiceUrl: String,
@Value("\${events.service.url:http://localhost:8085}") private val eventsServiceUrl: String,
@Value("\${zns.import.service.url:http://localhost:8095}") private val znsImportServiceUrl: String,
@Value("\${results.service.url:http://localhost:8088}") private val resultsServiceUrl: String,
@Value("\${series.service.url:http://localhost:8089}") private val seriesServiceUrl: String,
@Value("\${billing.service.url:http://localhost:8087}") private val billingServiceUrl: String
) {
class GatewayConfig {
@Bean
fun customRouteLocator(builder: RouteLocatorBuilder): RouteLocator {
@@ -31,31 +22,31 @@ class GatewayConfig(
it.fallbackUri = java.net.URI.create("forward:/fallback/ping")
}
}
uri(pingServiceUrl)
uri("lb://ping-service")
}
route(id = "masterdata-service") {
path("/api/v1/masterdata/**")
uri(masterdataServiceUrl)
uri("lb://masterdata-service")
}
route(id = "events-service") {
path("/api/v1/events/**")
uri(eventsServiceUrl)
uri("lb://events-service")
}
route(id = "zns-import-service") {
path("/api/v1/import/zns/**", "/api/v1/import/zns")
uri(znsImportServiceUrl)
uri("lb://zns-import-service")
}
route(id = "results-service") {
path("/api/v1/results/**")
uri(resultsServiceUrl)
uri("lb://results-service")
}
route(id = "series-service") {
path("/api/v1/series/**")
uri(seriesServiceUrl)
uri("lb://series-service")
}
route(id = "billing-service") {
path("/api/v1/billing/**")
uri(billingServiceUrl)
uri("lb://billing-service")
}
}
}
@@ -25,13 +25,13 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8081
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
gateway:
httpclient: { }
# Routen sind in GatewayConfig.kt definiert
# Routen sind in GatewayConfig.kt via Service-Discovery (lb://) definiert
# --- SECURITY (OAuth2 Resource Server) ---
security:
@@ -66,9 +66,3 @@ management:
# Lokal: Zipkin auf Port 9411. In Docker via ENV MANAGEMENT_ZIPKIN_TRACING_ENDPOINT überschrieben.
endpoint: ${MANAGEMENT_ZIPKIN_TRACING_ENDPOINT:http://localhost:9411/api/v2/spans}
# --- Custom Service URLs ---
# Default: Localhost (für Entwicklung ohne Docker)
# Im Docker-Compose überschreiben wir das mit dem Service-Namen
ping:
service:
url: ${PING_SERVICE_URL:http://localhost:8082}
@@ -15,12 +15,12 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8089
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
server:
port: ${SERVER_PORT:${BILLING_SERVICE_PORT:8087}}
port: 8089
management:
endpoints:
@@ -21,7 +21,7 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8083
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
@@ -22,7 +22,7 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8085
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
@@ -1,5 +1,5 @@
server:
port: ${SERVER_PORT:${IDENTITY_SERVICE_PORT:8088}}
port: 8087 # identity-service port
spring:
application:
@@ -18,7 +18,7 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8087
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
security:
@@ -32,12 +32,12 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8092
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
server:
port: 8085
port: 8092
management:
endpoints:
@@ -22,10 +22,10 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port} # Tomcat Port für Health Checks
health-check-port: 8086 # Spring Boot Management Port (Actuator)
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
port: ${masterdata.http.port} # Ktor API Port registrieren
port: ${masterdata.http.port:8091} # Ktor API Port registrieren (Gateway Ziel)
server:
port: 8086 # Spring Boot Management Port (Actuator & Tomcat)
@@ -50,7 +50,7 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8082
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
@@ -22,12 +22,12 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8088
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
server:
port: ${SERVER_PORT:${RESULTS_SERVICE_PORT:8084}}
port: 8088
management:
endpoints:
@@ -16,12 +16,12 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8094
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
server:
port: 8089
port: 8094
management:
endpoints:
@@ -22,12 +22,12 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8093
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
server:
port: 8090
port: 8093
management:
endpoints:
@@ -3,6 +3,7 @@ plugins {
alias(libs.plugins.kotlinSpring)
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependencyManagement)
alias(libs.plugins.kotlinSerialization)
}
springBoot {
@@ -4,11 +4,13 @@ import at.mocode.zns.import.service.job.ImportJob
import at.mocode.zns.import.service.job.ImportJobRegistry
import at.mocode.zns.import.service.job.ZnsImportOrchestrator
import at.mocode.zns.importer.ZnsImportMode
import kotlinx.serialization.Serializable
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
@Serializable
data class ImportStartResponse(val jobId: String)
@RestController
@@ -1,12 +1,15 @@
package at.mocode.zns.import.service.job
import kotlinx.serialization.Serializable
import org.springframework.stereotype.Component
import java.util.concurrent.ConcurrentHashMap
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid
@Serializable
enum class ImportJobStatus { AUSSTEHEND, ENTPACKEN, VERARBEITUNG, ABGESCHLOSSEN, FEHLER }
@Serializable
data class ImportJob(
val jobId: String,
var status: ImportJobStatus = ImportJobStatus.AUSSTEHEND,
@@ -31,7 +31,7 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 15s
health-check-port: ${server.port}
health-check-port: 8095
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
management: