【问题标题】:Spring Hystrix Single Fallback with Method Arguments Not Matching方法参数不匹配的 Spring Hystrix 单一后备
【发布时间】:2016-06-05 15:40:52
【问题描述】:

我想知道是否可以实现以下类似的东西,因为我有很多端点变体,并且每个端点都有一个带有匹配参数的后备方法非常混乱。或者,全局后备也可以。

@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】:

    Hystrix 提供默认方法支持。

    您可以通过以下方式使用它 - @HystrixCommand(defaultFallback = "fallback")

    【讨论】:

      猜你喜欢
      • 2017-12-27
      • 2018-03-08
      • 2015-06-13
      • 2017-10-18
      • 2018-06-21
      • 2018-03-07
      • 2021-03-29
      • 1970-01-01
      • 2018-02-16
      相关资源
      最近更新 更多