【发布时间】:2016-10-31 09:12:25
【问题描述】:
我有一个如下所示的服务层接口:
public interface MyService {
void save(DomainClass domainObject) throws MyServiceException;
}
我使用Hystrix保护实现方法:
public class MyServiceImpl implements MyService {
@HystrixCommand
public void save(DomainClass domainObject) throws MyServiceException {
remoteServiceClient.persist(domainObject);
}
}
当remoteServiceClient 失败或超时时,Hystrix 抛出HystrixRuntimeException。但我不希望服务的客户看到任何与 Hystrix 相关的异常(他们应该忘记服务的实现细节,对吧?)。我想抛出我的MyServiceException 检查异常。有可能这样做吗?我应该以不同的方式构建我的实现吗?
【问题讨论】: