How msomasun/demo-springconfig-repo works
Project type and purpose
• This is a Spring-based demo project illustrating a Config Server/Config Client pattern with automatic runtime refresh of configuration properties.
• Key functionality:
• A Config Server serves properties from an external repository (e.g., Git).
• One or more Config Clients fetch their configuration from the server and refresh when the config changes.
Infer the (implied) file structure and components
Even though the repo only contains a README, we know a typical Spring Cloud Config demo contains at least two subprojects (or modules):
– config-server (a Spring Boot app with @EnableConfigServer)
– config-client (a Spring Boot app annotated with @RefreshScope and using spring-cloud-config)
There may also be:
– an external configuration store (e.g., a Git repo or native filesystem)
– Spring Actuator endpoints for /refresh
– (optionally) Spring Cloud Bus with a message broker like RabbitMQ or Kafka to broadcast refresh events
Main components
a. External Config Store
• Git repository (or filesystem) containing application-name.properties/YAML
b. Config Server
• Spring Boot application annotated with @EnableConfigServer
• Exposes HTTP endpoints (/application/{profile}/{label})
• Reads from the external store and serves JSON/YAML payloads
c. Config Client(s)
• One or more Spring Boot microservices that:
– Use spring.cloud.config.uri to contact the Config Server at startup
– Have beans annotated with @RefreshScope
– Expose the Actuator /refresh endpoint
d. (Optional) Spring Cloud Bus and Message Broker
• Message broker (RabbitMQ/Kafka)
• Config Server or any client can POST to /actuator/bus-refresh to broadcast a refresh event
Relationships and interactions
1) On startup, each Config Client sends an HTTP GET to the Config Server to retrieve its configuration.
2) Config Server reads from the external store and returns the config payload.
3) When config files change in the external store (e.g., a Git commit), an operator or webhook triggers the Config Server to send a /refresh or /bus-refresh event.
4) If using Spring Cloud Bus: the event goes to the message broker, which fans out to all subscribed clients.
5) Each Config Client receives the event, refreshes its @RefreshScope beans, and applies new settings at runtime.
Architectural patterns and design principles
• “Externalized Configuration” (12-Factor App)
• “Configuration Server” as a centralized config store
• “Dynamic Refresh” using Actuator and Spring Cloud Bus
• Microservices style: each service is independently deployable and fetches its own config
Technologies, frameworks, and libraries
• Spring Boot (for both server and client)
• Spring Cloud Config Server / Client
• Spring Boot Actuator (/refresh, /env)
• (Optional) Spring Cloud Bus with RabbitMQ/Kafka
• Git (or filesystem) as the external config repository