相当于dubbo中的zookeeper
1 架构图
2 Server(应用服务)
- Artemis RegistryClient在启动时会先清除Artemis服务中的实例信息。
- Register: 服务端进行自身的健康监测机制,检测通过后Artemis Client会将服务注册到Artemis。
- UnRegister:服务端进程终止的时候,会向Artemis服务发送UnRegister请求,反注册实例信息。
- HeartBeat:Artemis RegistryClient维持与Artemis Service之间的心跳,每5秒钟报告一次。
- Artemis:如果Artemis RegistryClient在一定的时间内没有报告心跳,Artemis会认为实例已经终止,把实例状态置为Down,并向客户端推送实例状态变更。
- Artemis Client与Artemis Service建立Socket连接,默认TTL时间为5分钟,每5分钟需要与服务端重新建立一次连接,以保证负载均衡和DR切换。
3 Client(应用客户端)
- 应用客户端根据服务名和命名空间构建ServiceKey。
- Pull: Artemis DiscoveryClient从缓存中获取Service Context,如果缓存中未命中就会根据ServiceKey发起远程Http请求,从Artemis Service同步服务信息,如实例、路由规则等信息。
- Push: 当Artemis Service中的实例发生改变时(拉入、拉出、实例终止),会通过ServiceChangeListener告诉Artemis DisocveryClient,并更新客户端缓存。
- 每15分钟会从同步一次Artemis Service地址的路由表。
4 Artemis服务
- 对于新扩容的机器,Artemis服务会每隔5分钟全量同步CMS的应用和服务器数据,核对AppId和IP的关系,然后再推送到客户端,大概延迟在10分钟左右。