注册中心与服务发现(motan:registry)
介绍
注册中心配置。用于配置注册中心的注册协议、地址端口、超时时间等。motan:registry包含以下常用属性:
- name:标识配置名称
- regProtocol:标识注册中心协议
- address:标识注册中心地址Motan支持使用多种Registry模块,使用不同注册中心需要依赖对应jar包。
使用Consul作为注册中心
- <motan:registry regProtocol="consul" name="my_consul" address="consul_port:port"/>
使用Zookeeper作为注册中心
zookeeper为单节点
```xml
<motan:registry regProtocol="zookeeper" name="my_zookeeper" address="zookeeper_ip1:port"/>
```
zookeeper多节点集群
```xml
<motan:registry regProtocol="zookeeper" name="my_zookeeper" address="zookeeper_ip1:port1,zookeeper_ip2:port2,zookeeper_ip3:port"/>
```
不使用注册中心
在开发及测试环境下,经常需要绕过注册中心,只测试指定服务提供者,这时候可能需要点对点直连,点对点直联方式:
- <motan:registry regProtocol="direct" name="directRegistry" port="8002" address="192.168.1.2" />
or
<motan:registry regProtocol="direct" name="directRegistry" address="192.168.1.2:8002,192.168.1.3:8002" />