@HystrixCommand(fallbackMethod ="hellFallback", ignoreExceptions = HystrixBadRequestException.class)
@RequestMapping(value ="/say", method = RequestMethod.GET)
public String add() {
return restTemplate.getForEntity("http://HELLO-SERVICE/say",
String.class).getBody();
}
@HystrixCommand(fallbackMethod ="xxxx")
public String hellFallback(Throwable t)throws Throwable {
return restTemplate.getForEntity("http://HELLO-SERVICE/say2",
String.class).getBody();
}
public String xxxx() {
return "error";
}
在方法上 fallbackMethod指定降级方法,还可以指定忽略的异常,不进行降级,还可以异常获取。
网友评论