Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dubbo 2.7.5 服务分组,provider服务接口提供多个group,注册中心只看到一个 #5779

Closed
gaotingwang opened this issue Feb 23, 2020 · 1 comment
Assignees
Milestone

Comments

@gaotingwang
Copy link

Environment

  • Dubbo version: 2.7.5
  • Operating System version: macOS
  • Java version: 1.8

Steps to reproduce this issue

  1. 使用服务分组功能,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() {
        ...
    }

}
  1. 使用了zk做服务注册中心
  2. 在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相同。

有什么解决办法吗?还是我本身使用哪里出了问题,导致服务分组功能不可用

@mercyblitz mercyblitz self-assigned this Feb 25, 2020
@mercyblitz mercyblitz added this to the 2.7.6 milestone Feb 25, 2020
@mercyblitz
Copy link
Contributor

This issue has been fixed, but you have to wait for the 2.7.6 release. If you'd like to fix it in the emergency, I suggest you copy the code https://github.com/apache/dubbo/blob/master/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/config/DubboConfigDefaultPropertyValueBeanPostProcessor.java, and define it as the Spring Bean.

mercyblitz added a commit to mercyblitz/dubbo that referenced this issue Feb 25, 2020
mercyblitz added a commit that referenced this issue Feb 28, 2020
…erface (#5801)

* Polish /#5745 : Increasing the stack size in the start.sh

* Polish /#5297 : Only one of the multiple registration centers using nacos can register

* Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费

* Polish /#5442 : Merge upstream/master

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /apache/dubbo##5239 : Mock字段注入异常

* Polish /#5770 : Removing the interinal JDK API from FileSystemDynamicConfiguration

* Polish /#5771 : [Enhancement] Refactor the APT test-cases implementation of dubbo-metadata-processor in Java 9+

* Bugfix for the test-cases

* Polish /#5779 : Rename the local variables

* Add FieldUtils

* Polish /#5795 : [Feature] To support the application choose the preferred network interface

* Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants