Zookeeper notes (vii) application of zookeeper in Dubbo

Source: Internet
Author: User
Tags zookeeper client

application of zookeeper in Dubboarchitecture of the Dubbo

Node role Description:

Provider: The service provider that exposes the service.
Consumer: Invokes the service consumer of the remote service.
Registry: Registration Center for service Registration and discovery.
Monitor: The monitoring center of the call times of the statistics service and the call time.
Container: The service runs the container.
Call Relationship Description:

0. The service container is responsible for starting, loading, and running the service provider.
1. Upon launch, the service provider registers its services with the registry.
2. When the service consumer starts, it subscribes to the registration center for the services it needs.
3. The registry returns the service provider address list to the consumer, and if there is a change, the registry will push the change data to the consumer based on a long connection.
4. Service consumers, from the provider address list, based on the soft load equalization algorithm, select a provider to make the call, if the call fails, then choose another call.
5. Service consumers and providers, the cumulative number of calls in memory and call time, timed to send statistics every minute to the monitoring center.

Dubbo recommended to use the Zookeeper Registration center

Process Description:

When the service provider starts
Write your own URL address to the/dubbo/com.foo.barservice/providers directory.
When the service consumer starts
Subscribe to the provider URL address under the/dubbo/com.foo.barservice/providers directory.
and write your own URL address to the/dubbo/com.foo.barservice/consumers directory.
When the monitoring center starts
Subscribe to all provider and consumer URL addresses in the/dubbo/com.foo.barservice directory.

The following features are supported:

The registry can automatically delete provider information when a provider has an abnormal outage such as a power outage.
When the registry restarts, the registration data can be automatically restored, as well as the subscription request.
When the session expires, the registration data can be automatically restored, as well as the subscription request.
When setting <dubbo:registry check= "false"/>, logging failed registration and subscription requests, background timed retry.
You can set/> login information by <dubbo:registry username= "admin" password= "1234" zookeeper.
The root node of zookeeper can be set by <dubbo:registry group= "Dubbo"/>, and no root tree will be used.
Support for the * number wildcard <dubbo:reference group= "*" version= "*"/>, all groupings and providers of all versions of the service can be subscribed to.

Add the Zookeeper Client jar package dependency in provider and consumer:

<dependency><groupid>org.apache.zookeeper</groupid><artifactid>zookeeper</ Artifactid><version>3.3.3</version></dependency>

  

or direct download: Http://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper

Zkclient Client implementations:

Zkclient Zookeeper Registry

Starting with version 2.2.0, the default is Zkclient implementation to enhance the health of the zookeeper client.

Zkclient is datameer Open source of a zookeeper client implementation, open source earlier, see: Https://github.com/sgroschupf/zkclient

Default configuration:

<dubbo:registry client= "Zkclient"/>

Or:

Dubbo.registry.client=zkclient

Or:

Zookeeper://10.20.153.10:2181?client=zkclient

Depends on:

<dependency><groupid>com.github.sgroschupf</groupid><artifactid>zkclient</ Artifactid><version>0.1</version></dependency>

  

or direct download: http://repo1.maven.org/maven2/com/github/sgroschupf/zkclient

Zookeeper stand-alone configuration:

<dubbo:registry address= "zookeeper://10.20.153.10:2181"/>or:<dubbo:registry protocol= "zookeeper" address = "10.20.153.10:2181"/>

  

Zookeeper Cluster configuration:

<dubbo:registry address= "zookeeper://10.20.153.10:2181?backup=10.20.153.11:2181,10.20.153.12:2181"/>Or: <dubbo:registry protocol= "Zookeeper" address= "10.20.153.10:2181,10.20.153.11:2181,10.20.153.12:2181"/>

  

The same zookeeper, divided into several groups of registration centers:

<dubbo:registry id= "Chinaregistry" protocol= "Zookeeper" address= "10.20.153.10:2181" group= "China"/><dubbo : Registry id= "Intlregistry" protocol= "Zookeeper" address= "10.20.153.10:2181" group= "Intl"/>

  

Transfer from Dubbo User Guide

Zookeeper notes (vii) application of zookeeper in Dubbo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.