Integration of springBoot and dubbo, how to configure multiple registries on the consumer side

because multiple provider are registered on two zookeeper, when using spring before, it uses dubbo configuration file and defines multiple registry, which can be distinguished by id.

<dubbo:registry id="test1" protocol="zookeeper" address="${dubbo.address}" />
<dubbo:registry id="test2" protocol="zookeeper" address="${dubbo.address1}" />

<dubbo:reference registry="test1" id="cityDubboService" interface="com.example.demo.CityDubboService" check="false" />

change the customer side to use the springboot framework and call provider in the form of annotations.

application.properties add dubbo-related call information to the configuration file

spring.dubbo.application.name=consumer
spring.dubbo.application.registries[0].address=zookeeper:-sharp127.0.0.1:2181
spring.dubbo.application.registries[0].registry="test1"
spring.dubbo.application.registries[1].address=zookeeper:-sharp127.0.0.2:2181
spring.dubbo.application.registries[1].registry="test2"
spring.dubbo.scan=com.example.demo.controller

add comments on the call and the argument is

@Reference(registry="test1")
CityDubboService cityDubboService;

cannot call the dubbo side object (Note: the same code, the single registry call is successful, so there should be no problem on the provider side. The problem may occur in the configuration of the browser side, as shown above)

May.23,2022

encountered the same problem. I wrote registry bean and specified it myself, but it seems to be invalid


time: 2019-01-22
this answer is based on the springboot2.x version.
1. The dependent version is officially recommended. Since dubbo has been donated to apache, the Dubbo Spring Boot Starter recommended by the official website is used for integration, as follows:
http://dubbo.apache.org/zh-cn...

.

clipboard.png

2@EnableDubbo(multipleConfig = true),multipleConfigfalsetrue

clipboard.png

3 id
http://dubbo.apache.org/zh-cn...
:

clipboard.png
has been tested and the configuration dubbo.registry.c1.address=zookeeper://127.0.0.1:2181 does not work.
needs to be changed to [ dubbo.registries.c1.address=zookeeper://127.0.0.1:2181 ], where C1 represents the id of this group of zk.

Finally, to sum up, there are many answers to this kind of questions, all about how to match the cluster. We can only say that those who answer how to match the cluster do not even understand the questions.


1, registry address should be zookeeper://xxxx, not with-sharp.
2Spring.dubbo.registries type is Map < String, RegistryConfig >. Your way of writing is List assignment, not Map assignment.
you should write
spring.dubbo.registries.xxx.address=zookeeper://xxxx
spring.dubbo.registries.xxx.id=local
spring.dubbo.registries.yyy.address=zookeeper://xxx
spring.dubbo.registries.yyy.id=server
xxx and yyy at will


< H1 > my own consumer multi-registration configuration may not be recognized by admin but must be successful. You can call < / H1 >.
-sharp   zookeeper://  zookeeper
dubbo.registry.protocol=zookeeper
-sharp  registry12   
dubbo.registries.registry1.address=zookeeper://127.0.0.1:2181
dubbo.registries.registry2.address=zookeeper://127.0.0.1:2182
-sharp
dubbo.registries.registry2.default=true
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c77b-2c311.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c77b-2c311.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?