Dubbo目前支持4种注册中心,(multicast zookeeper redis simple) |
推荐使用Zookeeper注册中心, |
相关概念解析:
<
dubbo:registry
address
=
"multicast://224.5.6.7:1234"
/>
|
Or:
<
dubbo:registry
protocol
=
"multicast"
address
=
"224.5.6.7:1234"
/>
|
为了减少广播量,Dubbo缺省使用单播发送提供者地址信息给消费者,
如果一个机器上同时启了多个消费者进程,消费者需声明unicast=false,否则只会有一个消费者能收到消息:
<
dubbo:registry
address
=
"multicast://224.5.6.7:1234?unicast=false"
/>
|
Or:
<
dubbo:registry
protocol
=
"multicast"
address
=
"224.5.6.7:1234"
>
<
dubbo:parameter
key
=
"unicast"
value
=
"false"
/>
dubbo:registry
>
|
流程说明:
支持以下功能:
在provider和consumer中增加zookeeper客户端jar包依赖:
<
dependency
>
<
groupId
>org.apache.zookeeper
groupId
>
<
artifactId
>zookeeper
artifactId
>
<
version
>3.3.3
version
>
dependency
>
|
或直接下载:http://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper
支持zkclient和curator两种Zookeeper客户端实现:
从2.2.0版本开始缺省为zkclient实现,以提升zookeeper客户端的健状性。
缺省配置:
<
dubbo:registry
...
client
=
"zkclient"
/>
|
或:
dubbo.registry.client=zkclient
|
或:
zookeeper://10.20.153.10:2181?client=zkclient
|
需依赖:
<
dependency
>
<
groupId
>com.github.sgroschupf
groupId
>
<
artifactId
>zkclient
artifactId
>
<
version
>0.1
version
>
dependency
>
|
或直接下载:http://repo1.maven.org/maven2/com/github/sgroschupf/zkclient
从2.3.0版本开始支持可选curator实现。
如果需要改为curator实现,请配置:
<
dubbo:registry
...
client
=
"curator"
/>
|
或:
dubbo.registry.client=curator
|
或:
zookeeper://10.20.153.10:2181?client=curator
|
需依赖:
<
dependency
>
<
groupId
>com.netflix.curator
groupId
>
<
artifactId
>curator-framework
artifactId
>
<
version
>1.1.10
version
>
dependency
>
|
或直接下载:http://repo1.maven.org/maven2/com/netflix/curator/curator-framework
Zookeeper单机配置:
<
dubbo:registry
address
=
"zookeeper://10.20.153.10:2181"
/>
|
Or:
<
dubbo:registry
protocol
=
"zookeeper"
address
=
"10.20.153.10:2181"
/>
|
Zookeeper集群配置:
<
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"
/>
|
同一Zookeeper,分成多组注册中心:
<
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"
/>
|
数据结构:
调用过程:
选项:
Config redis registry:
<
dubbo:registry
address
=
"redis://10.20.153.10:6379"
/>
|
Or:
<
dubbo:registry
address
=
"redis://10.20.153.10:6379?backup=10.20.153.11:6379,10.20.153.12:6379"
/>
|
Or:
<
dubbo:registry
protocol
=
"redis"
address
=
"10.20.153.10:6379"
/>
|
Or:
<
dubbo:registry
protocol
=
"redis"
address
=
"10.20.153.10:6379,10.20.153.11:6379,10.20.153.12:6379"
/>
|
Export simple registry service:
<
dubbo:application
name
=
"simple-registry"
/>
<
dubbo:protocol
port
=
"9090"
/>
<
dubbo:service
interface
=
"com.alibaba.dubbo.registry.RegistryService"
ref
=
"registryService"
registry
=
"N/A"
ondisconnect
=
"disconnect"
callbacks
=
"1000"
>
<
dubbo:method
name
=
"subscribe"
><
dubbo:argument
index
=
"1"
callback
=
"true"
/>
dubbo:method
>
<
dubbo:method
name
=
"unsubscribe"
><
dubbo:argument
index
=
"1"
callback
=
"false"
/>
dubbo:method
>
dubbo:service
>
<
bean
id
=
"registryService"
class
=
"com.alibaba.dubbo.registry.simple.SimpleRegistryService"
/>
beans
>
|
Reference the simple registry service:
<
dubbo:registry
address
=
"127.0.0.1:9090"
/>
|
Or:
<
dubbo:service
interface
=
"com.alibaba.dubbo.registry.RegistryService"
group
=
"simple"
version
=
"1.0.0"
... >
|
<
dubbo:registry
address
=
"127.0.0.1:9090"
group
=
"simple"
version
=
"1.0.0"
/>
|
1.1 暴露一个简单监控中心服务到注册中心: (如果是用安装包,不需要自己写这个配置,如果是自己实现监控中心,则需要)
<
dubbo:application
name
=
"simple-monitor"
/>
<
dubbo:registry
address
=
"127.0.0.1:9090"
/>
<
dubbo:protocol
port
=
"7070"
/>
<
dubbo:service
interface
=
"com.alibaba.dubbo.monitor.MonitorService"
ref
=
"monitorService"
/>
<
bean
id
=
"monitorService"
class
=
"com.alibaba.dubbo.monitor.simple.SimpleMonitorService"
/>
beans
>
|
1.2 通过注册中心发现监控中心服务:
<
dubbo:monitor
protocol
=
"registry"
/>
|
或:
dubbo.monitor.protocol=registry
|
2.1 暴露一个简单监控中心服务,但不注册到注册中心: (如果是用安装包,不需要自己写这个配置,如果是自己实现监控中心,则需要)
<
dubbo:application
name
=
"simple-monitor"
/>
<
dubbo:protocol
port
=
"7070"
/>
<
dubbo:service
interface
=
"com.alibaba.dubbo.monitor.MonitorService"
ref
=
"monitorService"
registry
=
"N/A"
/>
<
bean
id
=
"monitorService"
class
=
"com.alibaba.dubbo.monitor.simple.SimpleMonitorService"
/>
beans
>
|
2.2 直连监控中心服务:
<
dubbo:monitor
address
=
"dubbo://127.0.0.1:7070/com.alibaba.dubbo.monitor.MonitorService"
/>
|
或:
<
dubbo:monitor
address
=
"127.0.0.1:7070"
/>
|
或:
dubbo.monitor.address=
127.0
.
0.1
:
7070
|
Dubbo目前支持4种注册中心,(multicast zookeeper redis simple) |
推荐使用Zookeeper注册中心, |
相关概念解析:
<
dubbo:registry
address
=
"multicast://224.5.6.7:1234"
/>
|
Or:
<
dubbo:registry
protocol
=
"multicast"
address
=
"224.5.6.7:1234"
/>
|
为了减少广播量,Dubbo缺省使用单播发送提供者地址信息给消费者,
如果一个机器上同时启了多个消费者进程,消费者需声明unicast=false,否则只会有一个消费者能收到消息:
<
dubbo:registry
address
=
"multicast://224.5.6.7:1234?unicast=false"
/>
|
Or:
<
dubbo:registry
protocol
=
"multicast"
address
=
"224.5.6.7:1234"
>
<
dubbo:parameter
key
=
"unicast"
value
=
"false"
/>
dubbo:registry
>
|
流程说明:
支持以下功能:
在provider和consumer中增加zookeeper客户端jar包依赖:
<
dependency
>
<
groupId
>org.apache.zookeeper
groupId
>
<
artifactId
>zookeeper
artifactId
>
<
version
>3.3.3
version
>
dependency
>
|
或直接下载:http://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper
支持zkclient和curator两种Zookeeper客户端实现:
从2.2.0版本开始缺省为zkclient实现,以提升zookeeper客户端的健状性。
缺省配置:
<
dubbo:registry
...
client
=
"zkclient"
/>
|
或:
dubbo.registry.client=zkclient
|
或:
zookeeper://10.20.153.10:2181?client=zkclient
|
需依赖:
<
dependency
>
<
groupId
>com.github.sgroschupf
groupId
>
<
artifactId
>zkclient
artifactId
>
<
version
>0.1
version
>
dependency
>
|
或直接下载:http://repo1.maven.org/maven2/com/github/sgroschupf/zkclient
从2.3.0版本开始支持可选curator实现。
如果需要改为curator实现,请配置:
<
dubbo:registry
...
client
=
"curator"
/>
|
或:
dubbo.registry.client=curator
|
或:
zookeeper://10.20.153.10:2181?client=curator
|
需依赖:
<
dependency
>
<
groupId
>com.netflix.curator
groupId
>
<
artifactId
>curator-framework
artifactId
>
<
version
>1.1.10
version
>
dependency
>
|
或直接下载:http://repo1.maven.org/maven2/com/netflix/curator/curator-framework
Zookeeper单机配置:
<
dubbo:registry
address
=
"zookeeper://10.20.153.10:2181"
/>
|
Or:
<
dubbo:registry
protocol
=
"zookeeper"
address
=
"10.20.153.10:2181"
/>
|
Zookeeper集群配置:
<
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"
/>
|
同一Zookeeper,分成多组注册中心:
<
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"
/>
|
数据结构:
调用过程:
选项:
Config redis registry:
<
dubbo:registry
address
=
"redis://10.20.153.10:6379"
/>
|
Or:
<
dubbo:registry
address
=
"redis://10.20.153.10:6379?backup=10.20.153.11:6379,10.20.153.12:6379"
/>
|
Or:
<
dubbo:registry
protocol
=
"redis"
address
=
"10.20.153.10:6379"
/>
|
Or:
<
dubbo:registry
protocol
=
"redis"
address
=
"10.20.153.10:6379,10.20.153.11:6379,10.20.153.12:6379"
/>
|
Export simple registry service:
<
dubbo:application
name
=
"simple-registry"
/>
<
dubbo:protocol
port
=
"9090"
/>
<
dubbo:service
interface
=
"com.alibaba.dubbo.registry.RegistryService"
ref
=
"registryService"
registry
=
"N/A"
ondisconnect
=
"disconnect"
callbacks
=
"1000"
>
<
dubbo:method
name
=
"subscribe"
><
dubbo:argument
index
=
"1"
callback
=
"true"
/>
dubbo:method
>
<
dubbo:method
name
=
"unsubscribe"
><
dubbo:argument
index
=
"1"
callback
=
"false"
/>
dubbo:method
>
dubbo:service
>
<
bean
id
=
"registryService"
class
=
"com.alibaba.dubbo.registry.simple.SimpleRegistryService"
/>
beans
>
|
Reference the simple registry service:
<
dubbo:registry
address
=
"127.0.0.1:9090"
/>
|
Or:
<
dubbo:service
interface
=
"com.alibaba.dubbo.registry.RegistryService"
group
=
"simple"
version
=
"1.0.0"
... >
|
<
dubbo:registry
address
=
"127.0.0.1:9090"
group
=
"simple"
version
=
"1.0.0"
/>
|
1.1 暴露一个简单监控中心服务到注册中心: (如果是用安装包,不需要自己写这个配置,如果是自己实现监控中心,则需要)
<
dubbo:application
name
=
"simple-monitor"
/>
<
dubbo:registry
|