Design and Architecture of JD's Virtual Order Center (Hamal)
The article explains the architecture and core mechanisms of JD's Virtual Order Center, describing how the Hamal service leverages MySQL binlog listening, Zookeeper coordination, fast TCP‑based consumption, read‑write separation, and multi‑level search to reliably process billions of virtual orders.
JD's Virtual Order Center is a public foundational service platform that aggregates complex non‑standard product models and massive personalized order data, providing customized structure, publishing, promotion, virtual asset payment, settlement, refund, and comprehensive order analytics for the virtual platform.
The center aggregates orders from virtual goods such as mobile top‑ups, fuel cards, tickets, and game cards, and supplies order data to JD's main order system, risk control, marketing, and other business units.
Its core functionality revolves around the Hamal service, which listens to MySQL binlog events with high availability and performance, converting raw binlog data into usable order information.
**Binlog Basics**: MySQL binlog records all data‑changing SQL statements in binary format, similar to Oracle's archive log, and can be used for change history, incremental backup, point‑in‑time recovery, and replication.
**Sync Listening Principle**: Hamal simulates MySQL master‑slave replication by registering as a slave (COM_REGISTER_SLAVE) and then requesting binlog events (COM_BINLOG_DUMP) with specified binlog file and position, receiving a stream of events that include DDL, DML, TCL, privileges, and row data.
-COM_BINLOG_DUMP -4byte binlog-pos -2byte flags (BINLOG_DUMP_NON_BLOCK ...) -4byte slave-server-id -nul-term binlog name**DML Binlog Event Types**:
enumLog_event_type { WRITE_ROWS_EVENT = 23, UPDATE_ROWS_EVENT = 24, DELETE_ROWS_EVENT = 25, INCIDENT_EVENT = 26, HEARTBEAT_LOG_EVENT = 27, };The overall architecture places Hamal at the data pipeline entrance, using Zookeeper to manage listener instances and record binlog consumption positions, enabling automatic failover and high‑availability with a 72‑hour SLA.
For fast consumption, Hamal adopts a TCP sliding‑window approach, batching binlog records, parsing them in parallel, and acknowledging via JMQ messages, which also drives downstream order processing such as deduplication, DML filtering, and storage.
Read‑write separation is achieved by persisting raw orders in MySQL, while Elasticsearch and cache systems provide indexed, searchable views, with DAO modules decoupled via JMQ.
The order gateway (GW) offers customizable data templates, subscription, pagination, and multi‑level search; if a search fails at one level, it falls back to the next, ultimately querying the product line database to ensure a complete user experience.
After two major version upgrades and multiple large‑scale promotional events, the Virtual Order Center now supports over 30 virtual business lines, handles nearly one billion orders, and continues to serve as a critical conduit for non‑standard goods within JD's e‑commerce ecosystem.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
JD Tech
Official JD technology sharing platform. All the cutting‑edge JD tech, innovative insights, and open‑source solutions you’re looking for, all in one place.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
