Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
fceaea4c
Commit
fceaea4c
authored
Jun 30, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改介绍
parent
cc293c4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
README.md
+12
-7
No files found.
README.md
View file @
fceaea4c
...
@@ -14,8 +14,9 @@ Nepxion Discovery是一款对Spring Cloud Discovery的服务注册增强插件
...
@@ -14,8 +14,9 @@ Nepxion Discovery是一款对Spring Cloud Discovery的服务注册增强插件
3. 实现通过下面两种推送方式,动态改变“服务发现层面的控制”
3. 实现通过下面两种推送方式,动态改变“服务发现层面的控制”
4. 实现通过XML进行规则定义
4. 实现通过XML进行规则定义
5. 实现通过事件总线机制(EventBus)异步对接远程配置中心,接受远程配置中心主动推送规则信息
5. 实现通过事件总线机制(EventBus)异步对接远程配置中心,接受远程配置中心主动推送规则信息
6. 实现通过事件总线机制(EventBus)异步接受Rest主动推送规则信息
6. 实现通过事件总线机制(EventBus)
和Spring Boot Actuator,
异步接受Rest主动推送规则信息
7. 实现通过Listener机制便于使用者扩展更多过滤条件,也可以利用Listener实现服务注册发现核心事件的监听
7. 实现通过Listener机制便于使用者扩展更多过滤条件,也可以利用Listener实现服务注册发现核心事件的监听
8. 实现通过Spring Boot Actuator的集成,提供健康检查功能
## 场景
## 场景
...
@@ -255,9 +256,12 @@ http://IP:[server.port]/routeAll
...
@@ -255,9 +256,12 @@ http://IP:[server.port]/routeAll
使用者可以继承如下类
使用者可以继承如下类
```
xml
```
xml
AbstractRegisterListener,实现服务注册的扩展和监听
AbstractRegisterListener,实现服务注册的扩展和监听
AbstractDiscoveryListener,实现服务发现的扩展和监听
AbstractDiscoveryListener,实现服务发现的扩展和监听
,注意,在Consul下,同时会触发service和management两个实例的事件,需要区别判断,见图1
```
```
图1,集成了健康检查的Consul控制台

## Spring Cloud引入Consul的坑
## Spring Cloud引入Consul的坑
```
xml
```
xml
spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-api-1.2.2版本,它不兼容Consul的1.0.0以上的服务器,原因是服务的deregister在consul-api-1.2.2中是执行GET方法,而Consul的1.0.0以上的服务器对应的是PUT方法
spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-api-1.2.2版本,它不兼容Consul的1.0.0以上的服务器,原因是服务的deregister在consul-api-1.2.2中是执行GET方法,而Consul的1.0.0以上的服务器对应的是PUT方法
...
@@ -268,7 +272,7 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -268,7 +272,7 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
## 示例
## 示例
### 场景描述
### 场景描述
本例将模拟一个较为复杂的场景,如图
1
本例将模拟一个较为复杂的场景,如图
2
```
xml
```
xml
1. 调用关系服务A->服务B->服务C
1. 调用关系服务A->服务B->服务C
2. 服务A一个实例,服务B两个实例,服务C三个实例
2. 服务A一个实例,服务B两个实例,服务C三个实例
...
@@ -276,7 +280,7 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -276,7 +280,7 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
4. 当一切就绪后,动态切换规则,改变调用的版本对应关系
4. 当一切就绪后,动态切换规则,改变调用的版本对应关系
```
```
图
1
图
2


上述服务分别见discovery-springcloud-example字样的6个DiscoveryApplication,分别对应各自的application.properties。这6个应用,对应的版本和端口号如下表
上述服务分别见discovery-springcloud-example字样的6个DiscoveryApplication,分别对应各自的application.properties。这6个应用,对应的版本和端口号如下表
...
@@ -316,14 +320,14 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -316,14 +320,14 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
2. 通过Postman或者浏览器,执行GET http://localhost:1100/instances/discovery-springcloud-example-b,查看当前A服务可访问B服务的列表
2. 通过Postman或者浏览器,执行GET http://localhost:1100/instances/discovery-springcloud-example-b,查看当前A服务可访问B服务的列表
3. 通过Postman或者浏览器,执行GET http://localhost:1200/instances/discovery-springcloud-example-c,查看当前B1服务可访问C服务的列表
3. 通过Postman或者浏览器,执行GET http://localhost:1200/instances/discovery-springcloud-example-c,查看当前B1服务可访问C服务的列表
4. 通过Postman或者浏览器,执行GET http://localhost:1201/instances/discovery-springcloud-example-c,查看当前B2服务可访问C服务的列表
4. 通过Postman或者浏览器,执行GET http://localhost:1201/instances/discovery-springcloud-example-c,查看当前B2服务可访问C服务的列表
5. 通过Postman或者浏览器,执行POST http://localhost:1100/routeAll/,填入discovery-springcloud-example-b;discovery-springcloud-example-c,可以看到路由全路径,如图
2
结果
5. 通过Postman或者浏览器,执行POST http://localhost:1100/routeAll/,填入discovery-springcloud-example-b;discovery-springcloud-example-c,可以看到路由全路径,如图
3
结果
6. 通过Postman或者浏览器,执行POST http://localhost:5200/config/send,发送新的规则XML,那么在B1服务上将会运行新的规则,再运行上述步骤,查看服务列表
6. 通过Postman或者浏览器,执行POST http://localhost:5200/config/send,发送新的规则XML,那么在B1服务上将会运行新的规则,再运行上述步骤,查看服务列表
7. 通过Postman或者浏览器,执行POST http://localhost:5201/config/send,发送同样的规则XML,那么在B1服务上将会运行新的规则,再运行上述步骤,查看服务列表
7. 通过Postman或者浏览器,执行POST http://localhost:5201/config/send,发送同样的规则XML,那么在B1服务上将会运行新的规则,再运行上述步骤,查看服务列表
8. 通过Postman或者浏览器,执行GET http://localhost:5200/config/view,查看当前在B1服务已经生效的规则
8. 通过Postman或者浏览器,执行GET http://localhost:5200/config/view,查看当前在B1服务已经生效的规则
9. 通过Postman或者浏览器,执行GET http://localhost:5201/config/view,查看当前在B2服务已经生效的规则
9. 通过Postman或者浏览器,执行GET http://localhost:5201/config/view,查看当前在B2服务已经生效的规则
10.再执行步骤5,可以看到路由全路径将发生变化
10.再执行步骤5,可以看到路由全路径将发生变化
```
```
图
2
结果
图
3
结果
```
xml
```
xml
{
{
"serviceId": "discovery-springcloud-example-a",
"serviceId": "discovery-springcloud-example-a",
...
@@ -372,6 +376,6 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
...
@@ -372,6 +376,6 @@ spring-cloud-consul的2.0.0.RELEASE(目前最新的稳定版)支持consul-ap
}
}
```
```
图
2
图
3


\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment