Backend Development 21 min read

Refactoring the Supplier‑Product‑Adapter (SPA) System Using DDD and Spring WebFlux

This article presents a comprehensive case study of the SPA system used by Qunar, detailing its business and technical complexity, the adoption of Domain‑Driven Design and an adapter‑based architecture, the migration to Spring WebFlux for reactive asynchronous processing, and the measurable improvements achieved after refactoring.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Refactoring the Supplier‑Product‑Adapter (SPA) System Using DDD and Spring WebFlux

The SPA (Supplier‑Product‑Adapter) system integrates over 20 types of hotel‑booking agents and handles high QPS traffic, but accumulated legacy changes have made its business logic tangled, hard to maintain, and a major source of operational tickets.

Complexity analysis reveals duplicated processors, unclear business boundaries, and performance bottlenecks caused by deep asynchronous callbacks and a monolithic query object that couples all agents together.

To address these issues, the team chose Domain‑Driven Design (DDD) as the guiding methodology, splitting the domain into generic, core, and supporting sub‑domains, and applying knowledge‑crunching steps to extract a clear ubiquitous language and stable domain model.

The solution restructures the system around an adapter model (inbound/outbound adapters) and a shared kernel context that isolates mutable request data while keeping core quotation logic immutable. Business processing is reorganized into well‑defined stages (access, supplier‑chain, core‑chain) with only 26 essential processors.

For implementation, Spring WebFlux was selected to provide reactive, non‑blocking execution, better readability, and fine‑grained error handling (doOnError, onErrorReturn, onErrorResume). Reactive primitives Flux and Mono enable parallelization of independent sub‑flows via Mono.zip() and efficient thread‑pool isolation per agent type.

Refactoring principles emphasize focusing on the primary contradiction—simplifying the quotation flow—while deferring non‑core features to later phases, and empowering technical leads to prioritize high‑impact work.

Post‑refactor metrics show a reduction of processors from 70+ to 26, a 20 ms drop in response time, a 14 % decrease in development effort, a 33 % drop in ticket volume, and a halving of cyclomatic complexity, confirming the effectiveness of the DDD‑driven redesign.

Future work includes further segmentation of agent‑specific logic and continued optimization of non‑quotation workflows such as hotel and room‑type onboarding.

Javabackend architectureMicroservicesReactive ProgrammingDDDsystem refactoringSpring WebFlux
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.