I have a service layer interface that looks like this:
public interface MyService {
void save(DomainClass domainObject) throws MyServiceException;
}
I use Hystrix to protect the implementation method:
public class MyServiceImpl implements MyService {
@HystrixCommand
public void save(DomainClass domainObject) throws MyServiceException {
remoteServiceClient.persist(domainObject);
}
}
When the remoteServiceClient
fails or times out, Hystrix throws HystrixRuntimeException
. But I do not want the clients of the service to see any Hystrix related exceptions (they should be oblivious to the implementation details of the service, right?). I want to throw my MyServiceException
checked exception. Is it possible to do that? Should I structure my implementation in a different way?