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

ZK到NACOS同步时,因为dubbo的group为空,导致注册到nacos服务不匹配 #100

Closed
evancyz opened this issue Aug 18, 2019 · 4 comments

Comments

@evancyz
Copy link

evancyz commented Aug 18, 2019

现象:
nacos-sync建了一个同步任务,同步也成功了,但是在nacos的注册列表里是这样
providers:com.xxx.sms.api.service.xxxService:1.0.0
这个服务我们旧项目里没有grouopName

可是消费这个任务时,他的命名是这样:
consumers:com.piaoniu.sms.api.service.SmsService:1.0.0:
多了一个 结尾多了一个冒号 :

这个看起来在dubbo那边是符合预期的,这样就导致匹配不上了

查源码最后查出来是这个问题:

 /**
     * cteate Dubbo service name
     *
     * @param taskId task id
     * @param queryParam dubbo metadata
     */
    protected String getServiceNameFromCache(String taskId, Map<String, String> queryParam) {
        return nacosServiceNameMap
                .computeIfAbsent(taskId, (key) -> Joiner.on(":").skipNulls().join(CATALOG_KEY,
                        queryParam.get(INTERFACE_KEY), queryParam.get(VERSION_KEY),
                        queryParam.get(GROUP_KEY)));
    }

queryParam 这个变量,是从zk里读的,读出来因为没有groupName 所以为空。。这里就被skip掉了。。

我给 nacos 提了 issue,问题缘由都在这里 :
alibaba/nacos#1712

@evancyz evancyz changed the title ZK到NACOS同步时,因为groupName为空,导致主导到nacos服务不匹配的问题 ZK到NACOS同步时,因为dubbo的group为空,导致注册到nacos服务不匹配 Aug 18, 2019
@paderlol
Copy link
Contributor

这个问题似乎是dubbo建立消费者时不对吧?多一个冒号,从理论上讲最后为空组,应该什么都没有才对。

@evancyz
Copy link
Author

evancyz commented Aug 18, 2019

从dubbo 的 2.7.3 配置中心的重构来看 org.apache.dubbo.common.URLTest

@Test
    public void testGetColonSeparatedKey() {
        URL url1 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group&version=1.0.0");
        Assertions.assertEquals("org.apache.dubbo.test.interfaceName:1.0.0:group", url1.getColonSeparatedKey());

        URL url2 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&version=1.0.0");
        Assertions.assertEquals("org.apache.dubbo.test.interfaceName:1.0.0:", url2.getColonSeparatedKey());

        URL url3 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName&group=group");
        Assertions.assertEquals("org.apache.dubbo.test.interfaceName::group", url3.getColonSeparatedKey());

        URL url4 = URL.valueOf("10.20.130.230:20880/context/path?interface=org.apache.dubbo.test.interfaceName");
        Assertions.assertEquals("org.apache.dubbo.test.interfaceName::", url4.getColonSeparatedKey());
    }

默认无group的情况 他最后消费者的url 就是 最后会跟一个 冒号:

所以是dubbo重构那边的问题了么

@paderlol
Copy link
Contributor

嗯,跟Dubbo需要确认下,如果他们规定就是这么搞,那我这边改下,我个人是觉得似乎不太合理,没有的情况下跟一个冒号,不知道出于什么考虑。

@evancyz
Copy link
Author

evancyz commented Aug 18, 2019

是的。。我也觉得,我给他们提了issue。。apache/dubbo#4864 在这里。。

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