- 配置
spring:
application:
name: gateway-server
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
default-filters:
- name: Hystrix # 必须定义为Hystrix 只能是超时熔断
args:
name: fallbackmd
fallbackUri: forward:/fallback
- 定义熔断后fallback()
@RestController
public class FallbackController {
@RequestMapping("/fallback")
public String fallback() {
System.out.println("hystrix fallback");
return "hystrix fallback";
}
}
这种熔断只能针对服务网关调用后端服务接口超时才会生效,后端服务抛异常无效
网友评论