转载

springboot中使用dubbo多注册中心的配置方法

在工作中遇到dubbo多注册中心的需求

当前工程基于springboot 1.5.9.RELEASE dubbo 2.5.10

团队已经熟悉使用properties + springboot starter 这种方法配置集成的框架

下面是dubbo 多注册中心在 application.properties中的配置方法:

# 非常重要必须声明当前为多选方法
dubbo.config.multiple=true
# 注册中心1 命名为wallet
# 默认注册中心
dubbo.registries.wallet.default=true
dubbo.registries.wallet.protocol=zookeeper
dubbo.registries.wallet.client=zkclient
# 注册中心2 命名为pay
dubbo.registries.pay.protocol=zookeeper
dubbo.registries.pay.client=zkclient

消费者

引用注册中心pay中的接口,默认注册中心不用定义registry属性

@Reference(registry = "pay")
    private FukaAccountService fukaAccountService;

生产者

发布接口到注册中心pay,默认注册中心不用定义registry属性

@Service(registry = "pay")
    public class GetCardBalance extends ApiInvoker<APICardBalanceReq>{
原文  https://segmentfault.com/a/1190000019710242
正文到此结束
Loading...