Spring 如果没有回退方法,@HystrixCommand注释有什么用途?

Spring 如果没有回退方法,@HystrixCommand注释有什么用途?,spring,hystrix,Spring,Hystrix,我的项目中有以下代码 @HystrixCommand(groupKey = "AddressRepository", commandKey = "getAddressById", threadPoolKey = "addressSearchPool") public List<Address> getAddressById(String id) throws MyCustomException, HystrixRuntimeException { try (Conn

我的项目中有以下代码

@HystrixCommand(groupKey = "AddressRepository", commandKey = 
"getAddressById", threadPoolKey = "addressSearchPool")
public List<Address> getAddressById(String id)
  throws MyCustomException, HystrixRuntimeException {

     try (Connection con = sql2o.open()) {
         return // some logic....

     } catch (Sql2oException e) {
        throw new MyCustomException();
     } 
}
@HystrixCommand(groupKey=“AddressRepository”,commandKey=
“getAddressById”,threadPoolKey=“addressSearchPool”)
公共列表getAddressById(字符串id)
抛出MyCustomException、HystrixRuntimeException{
try(连接con=sql2o.open()){
返回//一些逻辑。。。。
}捕获(SQL2OE异常){
抛出新的MyCustomException();
} 
}
正如您所看到的,@HystrixCommand没有定义任何回退方法。我想知道HystrixCommand在这里的作用是什么

当没有定义回退时,使用HystrixCommand的用例是什么


代码是Spring应用程序的一部分

我认为,在失败的情况下返回默认响应不仅仅是hystrix的一个特点

停止级联故障。撤退和优雅的降级。快速失败 以及快速恢复

1) 如果不覆盖
getFallback
方法,将使用默认实现:

  protected R getFallback() {
        throw new UnsupportedOperationException("No fallback available.");
    }
尽管没有优雅的响应返回(只抛出异常),但fail fast原则仍然有效

2) 在回退方法中,通常返回空对象或集合。在某些情况下,您可能不希望在出现故障时返回空对象,但希望显示您的服务不工作,并返回一些5xx http状态代码和相应的消息