You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "huogithub (GitHub)" <gi...@apache.org> on 2020/03/30 02:32:47 UTC

[GitHub] [dubbo] huogithub opened issue #5937: dubbo2.7.5 多注册中心支持问题

<!-- 多注册中心配置,竖号分隔表示同时连接多个不同注册中心,同一注册中心的多个集群地址用逗号分隔 -->
    <dubbo:registry address="10.20.141.150:9090|10.20.154.177:9010" />
2.7.5用|分割解析url时报错



[ Full content available at: https://github.com/apache/dubbo/issues/5937 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [dubbo] huogithub commented on issue #5937: dubbo2.7.5 多注册中心支持问题

Posted by "huogithub (GitHub)" <gi...@apache.org>.
多中心配置实现
![图片](https://user-images.githubusercontent.com/12825873/77870299-98e26200-7273-11ea-9f6b-d483b5452bf2.png)

这种配置是在开发环境用,大部分服务都注册到一个中心,要开发的注册到另外新的中心,这样方便开发不用起太多微服务,有个需求就是自己本地的微服务不能注册到公共注册中心上只能注册到本地心中。开发启动一堆微服务很麻烦






[ Full content available at: https://github.com/apache/dubbo/issues/5937 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [dubbo] AlbumenJ commented on issue #5937: dubbo2.7.5 多注册中心支持问题

Posted by "AlbumenJ (GitHub)" <gi...@apache.org>.
因为目前的代码逻辑中获取注册中心的url中的参数并没有对连接多个注册中心做判断

```
// org.apache.dubbo.config.RegistryConfig

    public void setAddress(String address) {
        this.address = address;
        if (address != null) {
            try {
                URL url = URL.valueOf(address);
                setUsername(url.getUsername());
                setPassword(url.getPassword());
                updateIdIfAbsent(url.getProtocol());
                updateProtocolIfAbsent(url.getProtocol());
                updatePortIfAbsent(url.getPort());
                updateParameters(url.getParameters());
            } catch (Exception ignored) {
            }
        }
    }
```
上面代码中的 `url.getParameters()` 会将第二个注册中心的地址并入前面的参数中,即是 K-`register`,V-`false|zookeeper://127.0.0.1:2182`

你可以将 `registry.address` 中的 `?register=false` 去掉看能否正常运行,另官网也说到连接这种方式连接多个注册中心只是测试环境临时使用,所以并不建议使用这样的配置

[ Full content available at: https://github.com/apache/dubbo/issues/5937 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [dubbo] AlbumenJ commented on issue #5937: dubbo2.7.5 多注册中心支持问题

Posted by "AlbumenJ (GitHub)" <gi...@apache.org>.
因为目前的代码逻辑中获取注册中心的url中的参数并没有对连接多个注册中心做判断,你可以将`registry.address`中的`?register=false`去掉看能否正常运行,另官网也说到连接这种方式连接多个注册中心只是测试环境临时使用,所以并不建议使用这样的配置

[ Full content available at: https://github.com/apache/dubbo/issues/5937 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org