集成了Eureka
,Feign
,Hystrix
,Config
,Zuul
组件的Spring Cloud项目示例项目,四个模块需要分别启动
config
作为config-server
获取git上的分布式系统的配置, config-repo地址eureka-server
用于注册eureka
实例hystrix-dashboard
使用hystrix
仪表盘查看hystrix
的使用情况
- 显示eureka实例的运行状况: http://localhost:8761/
- 熔断器仪表盘,输入
http://localhost:8081/actuator/hystrix.stream
可查看feign-service
的熔断器使用情况: http://localhost:8761/hystrix - 获取
feign-service
的配置文件: http://localhost:8761/feign-service-develop.properties - 获取
feign-client
的配置文件: http://localhost:8761/feign-client-develop.properties - 获取
zuul-server
的配置文件: http://localhost:8761/zuul-server-develop.properties
config
用于从config-server
获取配置eureka-client
用于在eureka-server
上发现其他的eureka
客户端hystrix
熔断器,这里的示例用于异常处理
- 返回1/{number}的整数结果: http://localhost:8080/service/hystrix-test/1
- 通过计算除数为0的算式抛出运行时异常以触发
@HystrixCommand
: http://localhost:8080/service/hystrix-test/0 - 返回
feign-service
的eureka
实例名,供zuul-server
调用: http://localhost:8080/service/name
config
用于从config-server
获取配置eureka-client
用于在eureka-server
上发现其他的eureka客户端feign
用于调用feign-service
的接口
- 使用
feign
调用上述feign-service
的接口: http://localhost:8081/client/hystrix-test/0 - 返回
feign-client
的eureka
实例名,供zuul-server
调用: http://localhost:8081/client/name
模块中不编写任何接口,只通过zuul
调用feign-service
,feign-client
的接口
config
用于从config-server
获取配置eureka-client
用于在eureka-server
上发现其他的eureka
客户端zuul
起路由和过滤器的功能
- 使用过滤器处理,返回
feign-service
的eureka
实例名: http://localhost:8082/service/name - 使用过滤器处理,返回
feign-client
的eureka
实例名: http://localhost:8082/client/name