Multi-module Spring Boot ingest service for vehicle telemetry. Modules: - ingest-api / ingest-core / ingest-codec-common: shared SPI, dispatcher, Disruptor event bus, BCC/BCD codec helpers - protocol-gb32960: GB/T 32960.3 inbound (Netty + per-version parser packages v2016/v2025), platform login auth, VIN whitelist, idle handler - protocol-jt808 / protocol-jt1078 / protocol-jsatl12: JT/T inbound - inbound-mqtt / inbound-xinda-push: alternative ingest channels - session-core: per-channel session state - sink-archive / sink-mq: persistence sinks (local file / Kafka) - command-gateway: terminal control command gateway - bootstrap-all: aggregator Spring Boot app - observability: Micrometer / Actuator wiring Includes hex-dump golden samples under protocol-gb32960/src/test/resources and the GB/T 32960.3-2016 / 2025 reference PDFs under reference/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.2 KiB
3.2 KiB
架构决策记录(ADR 汇总)
本文件记录 lingniu-vehicle-ingest v2 的关键架构决策,后续每次重大调整追加条目(不删除旧条目)。
ADR-001 MQ 选型:Kafka
- Status: Accepted
- Context: 需要高吞吐、严格单车有序、成熟生态
- Decision: 使用 Kafka,分区 key = VIN
- Consequences: 下游消费者需使用消费组 + 分区内顺序消费;不使用 RocketMQ 的事务/顺序特性
ADR-002 线上消息格式:Protobuf
- Status: Accepted
- Context: 需要向前兼容、体积小、性能好
- Decision: 线上用 Protobuf,调试/诊断保留 JSON 序列化能力
- Consequences: 需维护
.protoschema,ingest-api模块负责生成 Java stub
ADR-003 command-gateway 独立模块
- Status: Accepted
- Context: 下行命令链路不应与接入进程耦合
- Decision: 拆出独立
command-gateway模块,复用session-core;本次重构同步交付 - Consequences: HTTP 对外接口(原 JT808Controller / JT1078Controller)迁移到此模块
ADR-004 信达 Push:保留模块但彻底重写
- Status: Accepted
- Context: 旧实现硬编码凭证、无重连、0300/0401 空实现
- Decision:
- 新模块
inbound-xinda-push隔离第三方库gps-push-client - 配置外置(yml + env)
- 自动重连 + Resilience4j 熔断
- 0200/0300/0401 仅做协议解析,转换为
VehicleEvent后直接投 Kafka - 业务处理全部下沉到下游消费者,本服务不再实现报警/透传业务逻辑
- 新模块
- Consequences: 旧代码 messageReceived 里的 TODO 不再回到本仓库;需要协调下游消费者团队认领
ADR-005 JT1078 / JSATL12 进第一批
- Status: Accepted
- Decision: 第一批迁移即覆盖 JT1078 信令 + JSATL12 报警附件上传
- Consequences: Phase 2 工期相应拉长;JSATL12 需要对象存储后端(本地 / S3 / OSS)
ADR-006 部署形态:all-in-one
- Status: Accepted
- Context: 当前规模无需按协议拆 Pod
- Decision: 生产默认
bootstrap-all,通过配置开关按需启停各协议模块 - Consequences: 单进程资源需求较高;未来若规模扩大可切换到
bootstrap-slim(保留能力,不交付)
ADR-007 Java 25 + 虚拟线程 + Disruptor
- Status: Accepted
- Decision:
- Netty EventLoop 只做解码与 RingBuffer 投递,严禁阻塞
- 业务 Handler 走虚拟线程(
Thread.ofVirtual()) - 协议间背压通过 Disruptor RingBuffer 表达
- 禁用
synchronized,使用ReentrantLock避免虚拟线程 pinning
- Consequences: 需开启
jdk.VirtualThreadPinnedJFR 监控
ADR-008 本服务不写业务库
- Status: Accepted
- Decision: 所有业务表(vehicle_data_actual / history / travel / gps_data 等)不再由本服务写入
- Consequences: 需要新建消费服务
vehicle-analytics-service承接;迁移期采用双跑对账
ADR-009 构建工具:Maven
- Status: Accepted
- Decision: 沿用 Maven,统一 BOM 管理版本,Spotless 格式化,ArchUnit 守护分层
ADR-010 框架:Spring Boot 3.4
- Status: Accepted
- Decision: Spring Boot 3.4.x,支持 JDK 25;AutoConfiguration 用于按需启停