带有方法参数不匹配的Spring Hystrix单回退

问题描述 投票:1回答:1

我想知道是否可以实现如下所示的方法,因为我有很多端点变体,并且每个端点都具有匹配参数的后备方法非常混乱。另外,全局回退也可以。

@RestController
@RequestMapping(value = "/rest")
class SomeRestController {


   @RequestMapping(value = "/test2", method = { RequestMethod.GET})
   @HystrixCommand(fallbackMethod = "fallback") // FIXME Will error here because arguments do not match
   public String test2(@RequestBody String body) {
    return "Test2";
   }

   @RequestMapping(value = "/test", method = { RequestMethod.GET})
   @HystrixCommand(fallbackMethod = "fallback")
   public String test() {
    return "Test";
   }

   public String fallback() {
    return "generic fallback"; // Return 503 and a message
   }

}
spring rest spring-boot hystrix circuit-breaker
1个回答
0
投票

Hystrix提供默认方法支持。

您可以按以下方式使用它-@HystrixCommand(defaultFallback =“ fallback”)

© www.soinside.com 2019 - 2024. All rights reserved.