Configuration Service
| GitHub Repository | https://github.com/AirCommerce/service-configuration |
The Configuration Service is the central backend microservice responsible for the lifecycle, validation, persistence, and cluster-wide distribution of dynamic configurations across the AirCommerce platform.
Architecture
Section titled “Architecture”The service is built on Spring Boot, MongoDB Replica Set, and Spring Cloud Bus over RabbitMQ:
- Atomic Transactions (ADR 0001: Transactional Configuration Edits): All writes, individual edits, and bulk namespace modifications are orchestrated through
MongoTransactionManager, providing ACID multi-document transaction guarantees across configuration entities. - Transactional Event Publishing: The service decouples database writes from external event delivery. A local application event is published within the transaction, and a transactional event listener (
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)) broadcasts the cloud event to RabbitMQ only after the MongoDB transaction successfully commits. This eliminates phantom invalidations during database rollbacks. - Typed Table Validation (ADR 0010: Typed Table Configuration):
ConfigurationType.TABLEconfigurations define typed columns (TableColumnType:INPUT,SWITCH,DROPDOWN,MULTISELECT) and matrix rows (TableRow/TableCell).TableConfigurationValidatorenforces column uniqueness, option sets, scalarvaluevs. listvaluesexclusivity, and required cells before persistence, mapping violations (InvalidTableConfigurationException) to HTTP400(ResponseCode.INVALID_REQUEST) and rolling back bulk transactions with zero emitted events.
Publish Flow
Section titled “Publish Flow”When an administrator edits a configuration through the Configuration UI or via direct REST invocations, the service coordinates the two-phase persistence and notification flow:
- REST Request: The client sends an HTTP
PUT /configurations/{id}orPUT /configurations/bulkrequest toConfiguration Controller. - Business Validation:
Configuration Servicevalidates data types, namespace constraints, and structure. - Transactional MongoDB Write:
Configuration Repositoryperforms an atomic write against the MongoDB Replica Set. - Local Event Staging: Upon successful write, the service publishes a local Spring application event, which is held until the transaction commit phase.
- Commit & Broadcast: On
AFTER_COMMIT, the transactional event listener dispatches aConfigurationChangedEventonto the RabbitMQ topic exchange. - Parallel Fanout: RabbitMQ broadcasts the message to subscribed consumer microservices matching the destination namespace pattern.
Consumer Usage Pattern
Section titled “Consumer Usage Pattern”Downstream microservices (such as businessOrchestratorService and iFlyResConnector) consume dynamic configurations via the embedded util-configuration library:
- Bootstrap: On startup, consumers fetch their namespace configurations using HTTP Feign from
Configuration APIand populate an in-memory Local Configuration Cache (ConcurrentHashMap). - Zero-Network Invalidation for Deletions (ADR 0002): When a
ConfigurationChangedEventwith actionDELETEDarrives over Spring Cloud Bus, the consumer immediately evicts the key from its local cache without issuing outbound HTTP calls. - Targeted Cache Refresh: When an event with action
CREATEDorUPDATEDarrives, the consumer evicts the stale cached value and makes a targetedGET /configurations/{key}call to repopulate the local cache.
Provided Interfaces
Section titled “Provided Interfaces”| Interface | Access |
|---|---|
| Configuration API | internal |
| Configuration Events Interface | internal |
Data Stores
Section titled “Data Stores”| Name | Kind |
|---|---|
| Configuration Database | Database |
| Configuration Events Queue | Message queue |
Consumed Interfaces
Section titled “Consumed Interfaces”None
Architecture Decisions
Section titled “Architecture Decisions”| ADR | Status | Date | Title |
|---|---|---|---|
| ADR-0010 | Accepted | 2026-11-20 | Typed Table Configuration |
| ADR-0006 | Accepted | 2026-10-13 | Dynamic Bus Routing for Custom Configuration Namespaces |
| ADR-0005 | Accepted | 2026-09-13 | Decoupled Maven Multi-Repo Architecture |
| ADR-0004 | Accepted | 2026-09-11 | Configuration Visibility Actuator Endpoint |
| ADR-0003 | Accepted | 2026-09-11 | Graceful Default Value Fallbacks |
| ADR-0002 | Accepted | 2026-09-11 | Comprehensive Configuration Lifecycle Events |
| ADR-0001 | Accepted | 2026-09-10 | Transactional Configuration Edits and Deferred Event Publishing |
High-Level Designs
Section titled “High-Level Designs”None