mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-10 17:00:30 +08:00
8b15445328
Former-commit-id: 1de24b7eb79676d1aba9d799a58c5a753290cf52
88 lines
3.5 KiB
Markdown
88 lines
3.5 KiB
Markdown
# 电梯应用 — 服务发现架构设计
|
||
|
||
**日期**:2026-05-01
|
||
**版本**:V2(与 V1 生产对齐)
|
||
**状态**:已实施
|
||
|
||
## 1. 核心决策
|
||
|
||
电梯应用(cw-elevator-application)的三个上游 Feign 客户端 **统一走 Dubbo/ZooKeeper 动态发现**,不依赖任何 `@RibbonClient` 定制或 `ConfigurationBasedServerList` 静态列表。
|
||
|
||
| 上游服务 | Feign 名称 | 发现方式 |
|
||
|---------|-----------|---------|
|
||
| 人脸识别 GPU | `ninca-crk-std` | Dubbo/ZooKeeper |
|
||
| 组织组件 | `ninca-common-component-organization` | Dubbo/ZooKeeper |
|
||
| 公共组件 | `ninca-common` | Dubbo/ZooKeeper |
|
||
|
||
## 2. 服务发现链路
|
||
|
||
```
|
||
ElevatorApplication
|
||
│ @EnableFeignClients(basePackages={...})
|
||
│
|
||
├── Feign Client ──→ Ribbon (默认) ──→ DiscoveryClient ──→ Dubbo Registry
|
||
│ │
|
||
│ zookeeper://10.0.22.207:2181
|
||
│ │
|
||
├── ZoneFeignClient → ninca-common ──────────────────┘
|
||
├── PersonRecordEventHandler → ninca-common-component-organization ─┘
|
||
└── ElevatorRecordSendTask → ninca-crk-std ────────────────────┘
|
||
```
|
||
|
||
**启动类**:`ElevatorApplication.java` — 无 `@RibbonClients` 注解,Ribbon 走默认 `DiscoveryClient` 模式。
|
||
|
||
## 3. 配置清单
|
||
|
||
### bootstrap.properties(生产)
|
||
|
||
```properties
|
||
server.port=16112
|
||
spring.application.name=elevator-app
|
||
spring.profiles.active=access-control
|
||
|
||
# Consul — 仅注册自身,不作为发现客户端
|
||
spring.cloud.consul.host=371bfca4972c43d2aefcf302d0a4a277
|
||
spring.cloud.consul.port=8500
|
||
spring.cloud.consul.discovery.enabled=false
|
||
|
||
# Dubbo/ZooKeeper — 服务发现
|
||
dubbo.registry.address=zookeeper://10.0.22.207:2181
|
||
dubbo.protocol.port=16107
|
||
dubbo.provider.version=1.0
|
||
```
|
||
|
||
### application.properties — 服务名映射
|
||
|
||
```properties
|
||
feign.ninca-crk-std.name=ninca-crk-std
|
||
feign.component-organization.name=ninca-common-component-organization
|
||
feign.ninca-common.name=ninca-common
|
||
```
|
||
|
||
> 以上均为 Feign 路由名称,不需 `ribbon.listOfServers` 或 `NIWSServerListClassName`。
|
||
|
||
## 4. V1 vs V2 对比
|
||
|
||
| | V1 生产 | V2(修复前) | V2(修复后) |
|
||
|------|---------|------------|------------|
|
||
| ninca-crk-std | Dubbo | ConfigurationBasedServerList(空→报错) | Dubbo |
|
||
| ninca-common-component-organization | Dubbo | ConfigurationBasedServerList(空→报错) | Dubbo |
|
||
| ninca-common | Dubbo | ConfigurationBasedServerList(空→报错) | Dubbo |
|
||
| @RibbonClients | 无 | 3 个 | **无** |
|
||
| RibbonConfiguration 类 | 无 | 3 个 | **无** |
|
||
|
||
## 5. 删除清单
|
||
|
||
| 文件 | 操作 |
|
||
|------|------|
|
||
| `NincaCrkStdRibbonConfiguration.java` | 删除 |
|
||
| `OrgServiceRibbonConfiguration.java` | 删除 |
|
||
| `CommonServiceRibbonConfiguration.java` | 删除 |
|
||
| `ElevatorApplication.java` 中 `@RibbonClients` 块 | 删除 |
|
||
|
||
## 6. 运维说明
|
||
|
||
- 若生产 ZooKeeper (`10.0.22.207:2181`) 不可达,三个 Feign 调用将报 `Load balancer does not have available server`——此为基础设施问题,非代码缺陷。
|
||
- `deploy/v2-maven/application.properties` 中无需添加 `*.ribbon.listOfServers`。
|
||
- 本地测试时可通过 `ninca-common-component-organization.ribbon.listOfServers=127.0.0.1:18082` 覆盖 DiscoveryClient 指向桩服务(需同时设置 `NIWSServerListClassName` 全局限定或通过 `@RibbonClient` 仅在测试 Profile 启用)。
|