-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Dubbo 2.7.5 服务分组,provider服务接口提供多个group,注册中心只看到一个 #5779
Copy link
Copy link
Closed
Milestone
Description
Environment
- Dubbo version: 2.7.5
- Operating System version: macOS
- Java version: 1.8
Steps to reproduce this issue
- 使用服务分组功能,provider提供多个group
@Service(version = "1.0", group = "group1", interfaceClass = GroupService.class)
public class GroupServiceImp1 implements GroupService {
@Override
public List<User> getUserInfo() {
...
}
}
@Service(version = "2.0", group = "group2", interfaceClass = GroupService.class)
public class GroupServiceImp2 implements GroupService {
@Override
public List<User> getUserInfo() {
...
}
}- 使用了zk做服务注册中心
- 在Doubbo-Admin中只能看到
group1的服务,看不到group2的服务,且consumer也只能调用group1的接口,group2提示No provider。
Actual Result
跟踪代码,在org.apache.dubbo.config.context.ConfigManager#addIfAbsent方法中:
static <C extends AbstractConfig> void addIfAbsent(C config, Map<String, C> configsMap, boolean unique) throws IllegalStateException {
if (config != null && configsMap != null) {
// 这里因为不同group的key是相同的,导致configsMap没有加入其它group的ServiceBean
String key = getId(config);
C existedConfig = (AbstractConfig)configsMap.get(key);
if (existedConfig != null && !config.equals(existedConfig)) {
if (logger.isWarnEnabled()) {
String type = config.getClass().getSimpleName();
logger.warn(...);
}
} else {
configsMap.put(key, config);
}
}
}而这里key是根据Interface进行setId,不同group的实现的是相同Interface,所以导致key相同。
有什么解决办法吗?还是我本身使用哪里出了问题,导致服务分组功能不可用
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.