泛化调用使用条件路由不生效
- [x] I have searched the issues of this repository and believe that this is not a duplicate.
- [x] I have checked the REAMDE of this repository and believe that this is not a duplicate.
Environment
- Dubbo Admin version: 0.3
- Registry center detail (type and version): Zookeeper version: 3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
- Operating System version: macOS Big Sur 11.4
- Java version: java version "1.8.0_241" Java(TM) SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
Steps to reproduce this issue
- 本地使用两个项目工程,A、B 两个工程,A 为 Provider,B 为 Consumer
- A 项目在 IDEA 中使用 Allow Parallel Run ,启动 2 个,端口分别为: 20882、21882
- A 项目中提供 1 个 User 服务组,version 为 0.0.1 ,里面具体有个服务方法为: listUser
- 并且在 A 项目中通过 XML 方式配置,示例:
<dubbo:service interface="xxx.xxx.CommonService" group="group_test" ref="userServiceImpl" version="0.0.1" protocol="dubbo"/>
CommonService 为泛化调用统一处理接口
5. 本地编译打包 Dubbo-admin ,(调用接口及配置标签路由均无问题),配置条件路由
6. 条件路由:
enabled: true
force: true
runtime: true
conditions:
- 'method = listUser => address = *:20882'
虽然有版本号、组 ,但是配置条件路由时候如果加上版本号或者组、或者两个都添加,均会提示找不到资源的错误,比如添加版本号提示:
Resource not found! Message:no existing condition route for path: config/dubbo/XXXXXUserService:0.0.1:.condition-router
不加则可以添加上规则,但是使用的时候不生效,跟踪 org.apache.dubbo.rpc.cluster.RouterChain#route 发现并没有配置上规则~ 7. B 项目使用 Dubbo GenericService 泛化调用
Expected Result
调用 user 里的 listUser 服务的时候,应该都请求到端口为 20882 的服务项目上!
Actual Result
实际仍然会请求到在 20882 和 21882 两个服务项目上
@Suremotoo 你好,通过你的描述,需要确认两个问题。
Dubbo版本提供一下;- 根据你第6点的描述,服务路由规则是否没有配置生效。需要
service+group+version才能确定一个服务;
@haoyann
Dubbo版本为:2.7.3- 我重新启动了项目和
zookeeper,已经可以正常添加服务了,但是泛化调用的时候,条件路由仍然是不生效的,我这里跟踪源码,大概发现了问题。
在 org.apache.dubbo.rpc.cluster.router.condition.ConditionRouter#matchCondition 方法中,由于我配置的是根据服务中的具体 method ,我的配置方法名为:listUserSeal , 所以条件是这样的:

正常来说 invocation.getMethodName(); ,应该是对应的方法名: listUserSeal,而泛化调用后,具体值为: $invoke,如下图,所以条件不生效!

当然,这仅仅是我使用条件路由 method 匹配发现的问题,其他情况我目前并未尝试!
不过,好像变成了 Dubbo 里的问题了,而不是 Dubbo-admin 的问题了 😅
其他条件应该是支持的,method, argument 有问题。