ZooKeeper registry
Zookeeper is a subproject of Apache Hadoop. It is a tree directory service that supports change push and is suitable for Dubbo service registries. It has high industrial intensity and can be used in production environments.
Process description:
- Service provider startup: to
/dubbo/com.foo.BarService/providers
Write your OWN URL address in the directory. - Service consumer startup: Subscribe
/dubbo/com.foo.BarService/providers
The provider URL in the directory. And to the/dubbo/com.foo.BarService/consumers
Write your OWN URL address in the directory. - Monitor center startup: Subscribe
/dubbo/com.foo.BarService
All provider and consumer urls under the directory.
Supports the following functions:
- The registry can automatically delete provider information when the provider has an abnormal outage such as power outage;
- When the registry is restarted, the registration data and subscription requests can be automatically restored.
- When the session expires, the registration data and subscription requests can be automatically restored.
- When setting
<dubbo:registry check="false" />
Failed registration and subscription requests are recorded, and the background periodically tries again. - through
<dubbo:registry username="admin" password="1234" />
Set zooKeeper login information. - through
<dubbo:registry group="dubbo" />
If the root node of ZooKeeper is not configured, the default root node is used. - support
*
The wildcard<dubbo:reference group="*" version="*" />
Providers for all groupings and versions of subscribeable services.
❝
As The old golden partner of Dubbo, ZooKeeper, we have already shared how to use Dubbo in our separate presentation. This article is a series of Spring Cloud Alibaba articles focusing on Nacos. So ZooKeeper won’t be talked about here.
❞
Nacos Registry
Nacos is an open source tool launched by Alibaba for service discovery and configuration management of distributed systems. Nacos is an important registry implementation in the Dubbo ecosystem.
Nacos official website: nacos. IO /zh-cn/
Github:github.com/alibaba/nac…
Preparatory work
Before you integrate Nacos into your Dubbo project, make sure the Nacos service is started in the background.
Quick learning
The steps for Dubbo to merge Nacos into a registry are simple and can be divided into “Adding Maven dependencies” and “configuring the registry.”
Rely on
The core dependencies are dubbo-Registry -nacos and nacos-client.
<! -- https://mvnrepository.com/artifact/org.apache.dubbo/dubbo-registry-nacos --> <dependency> < the groupId > org. Apache. Dubbo < / groupId > < artifactId > dubbo - registry - nacos < / artifactId > < version > 2.7.7 < / version > < / dependency > <! -- https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client --> <dependency> < the groupId > com. Alibaba. Nacos < / groupId > < artifactId > nacos - client < / artifactId > < version > 1.3.0 < / version > < / dependency >Copy the code
Configuring the Registry
The service provider and service consumer need only adjust the Address property configuration.
Single-machine configuration:
<! Dubbo :registry address=" Nacos ://127.0.0.1:8848"/> <! Dubbo: Registry protocol="nacos" address="127.0.0.1:2181"/>Copy the code
Cluster configuration:
<! - using Nacos registry, cluster - - > < dubbo: registry address = "Nacos: / / 192.168.10.101:2181? Backup = 192.168.10.102:2181192168 10.103:2181 "/ > <! - or - > < dubbo: registry protocol = "nacos" address = "192.168.10.101:2181192168 10.102:2181192168 10.103:2181" / >Copy the code
Then, restart your Dubbo application and Dubbo’s service offering and consumption information will be displayed in the Nacos console.
The author of this article: Mr. Hello Ward, welcome to follow. Click to get Java micro services Spring family bucket video course project materials.