美文网首页
Hystrix服务降级级联

Hystrix服务降级级联

作者: Britney_z | 来源:发表于2019-03-13 14:09 被阅读0次

@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指定降级方法,还可以指定忽略的异常,不进行降级,还可以异常获取。

相关文章

网友评论

      本文标题:Hystrix服务降级级联

      本文链接:https://www.haomeiwen.com/subject/kzizpqtx.html