Hi Ben,
Thanks for your answer. However my problem is a little different. To be more precise I'm developing a library based on Spring Cache that can be reused in many applications. For example:
@Cacheable(cache="cacheName", key = "#y")
public X x(String y) { .. }
It's inside the "cacheable implementation" that's triggered by the @Cacheable annotation where I want to use Hystrix as a circuit breaker around the call to the cache. I.e. x -> Hystrix -> cache. The reason for this is to make it transparent to the end user so that they don't have to setup and use a hystrix command explicitly for each call to the cache. So I cannot have a fallback logic inside the cache implementation that calls the original method (x) since I don't know what the original method is (this is not provided by Spring afaik). So what I do now is to return null as fallback strategy since then Spring knows that it should invoke the original method (actually null is also returned as a cache miss, and perhaps that's the root of the problem). The problem is that after the x() method returns Spring will try to put the result in the cache. But if the cache is down or is slow when doing the get request (resulting in the Hystrix fallback kicking in and returning null) then it's quite probable that the put request will also fail.
What approach would you recommend here? Or do you think it's bad practise to "hide" Hystrix in a library like this? Note that when I'm talking about "Hystrix" in this example it's for the cache only. My intention is that there will be another Hystrix command guarding x (with a different thread-pool) that the client must be more explicit about (but that's not my concern here).
Regards,
/Johan