Lucky-cloud
Lucky-cloud copied to clipboard
refactor: Replace OpenFeign service calls with Dubbo RPC (Spring Cloud Alibaba + Nacos integration)
Title
Replace OpenFeign service calls with Dubbo RPC (Spring Cloud Alibaba + Nacos integration)
Summary
Migrate existing inter-service calls that use OpenFeign to Dubbo RPC and use Nacos for service discovery/configuration. Goals: reduce network overhead, improve high-concurrency performance, and unify governance (services expose/reference interfaces via Dubbo).
Requirements (key points)
- Use Dubbo (recommend 3.x) for service exposure and consumption, with Nacos as the registry (keep Spring Cloud Alibaba environment).
- Preserve existing interface contracts (Java interfaces + DTOs) and aim for a non-invasive replacement.
- Provide timeout, retry, rate-limit and fallback strategies (can integrate Dubbo with Sentinel).
- Add unit/integration/contract tests to ensure behavioral parity.
- Provide a rollback plan: allow Feign and Dubbo to run in parallel temporarily to enable staged (canary) switch-over.
Tasks
- [ ] Add shared Dubbo config in
platform/common(Nacos registry, protocol, serialization, metadata-report). - [ ] Expose provider services as Dubbo providers (annotations/config) and register to Nacos.
- [ ] Replace Feign clients with Dubbo references on the consumer side (keep same Java interfaces where possible).
- [ ] Add circuit-breaker / rate-limiting / fallback strategies (recommend integrating Sentinel) and wire up monitoring metrics.
- [ ] Implement integration tests: provider/consumer local e2e, contract tests, timeout/retry/fallback scenarios.
- [ ] Update docs: developer onboarding, config reference, FAQ and rollback steps.
Acceptance Criteria
- Key service calls after migration behave the same (API semantics, exception behavior, timeout/retry policies).
- Nacos shows Dubbo service instances and service discovery works reliably.
- Performance/resource usage meets or improves upon Feign-based implementation.
Migration steps (brief)
- Prepare shared Dubbo config and publish it to config-center (Nacos).
- Enable Dubbo providers on target services while keeping Feign endpoints active; register providers to Nacos for canary.
- Switch some consumers to Dubbo invocation and validate in parallel (or route small percentage of traffic via gateway).
- Monitor errors, latency, QPS; expand canary after validation.
- Once stable, remove Feign code and fully switch to Dubbo.
Notes / Caveats
- Ensure DTOs are serializable and pick a compatible serialization (protobuf / fastjson2 / hessian2, etc.) per team standard.
- Maintain class/interface compatibility between consumer and provider versions.
- Evaluate gateway and cross-language scenarios (if non-Java clients exist, consider compatibility layer).
- Keep authentication/authorization controls at Dubbo layer or at gateway as required.