断路器的状态会暴露在Actuator提供的/health端点中,这样就可以直观地了解断路器的状态,下面通过一个实验,深入理解断路器的状态转换。
一 启动eureka
二 启动user微服务
三 确保电影微服务有下面的依赖,启动movie微服务
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
四 访问http://localhost:8010/user/1,获得正确结果
{"id":1,"username":"account1","name":"张三","age":20,"balance":100.00}
五 访问http://localhost:8010/health,得到如下结果: