Skip to content

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.

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.TABLE configurations define typed columns (TableColumnType: INPUT, SWITCH, DROPDOWN, MULTISELECT) and matrix rows (TableRow / TableCell). TableConfigurationValidator enforces column uniqueness, option sets, scalar value vs. list values exclusivity, and required cells before persistence, mapping violations (InvalidTableConfigurationException) to HTTP 400 (ResponseCode.INVALID_REQUEST) and rolling back bulk transactions with zero emitted events.

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:

  1. REST Request: The client sends an HTTP PUT /configurations/{id} or PUT /configurations/bulk request to Configuration Controller.
  2. Business Validation: Configuration Service validates data types, namespace constraints, and structure.
  3. Transactional MongoDB Write: Configuration Repository performs an atomic write against the MongoDB Replica Set.
  4. Local Event Staging: Upon successful write, the service publishes a local Spring application event, which is held until the transaction commit phase.
  5. Commit & Broadcast: On AFTER_COMMIT, the transactional event listener dispatches a ConfigurationChangedEvent onto the RabbitMQ topic exchange.
  6. Parallel Fanout: RabbitMQ broadcasts the message to subscribed consumer microservices matching the destination namespace 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 API and populate an in-memory Local Configuration Cache (ConcurrentHashMap).
  • Zero-Network Invalidation for Deletions (ADR 0002): When a ConfigurationChangedEvent with action DELETED arrives 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 CREATED or UPDATED arrives, the consumer evicts the stale cached value and makes a targeted GET /configurations/{key} call to repopulate the local cache.
Showing 2 of 2 interfaces
Showing 2 of 2 data stores

None

None