Recently I've been instructed to define some fallback for our existing feign clients in our spring boot projects. I did some research and apparently Hystrix
is the way to go.
After integrating it with the project, I noticed that every time I don't received desired response from the target service (for example when I receive a response with http status 403 instead of 200) , client switches to fallback method.
Well, That is not the desired flow in our case. After searching for solutions I did find out that HystrixCommand
s are the proper way to handle this problem. According to this I could use @HystrixCommand to prevent triggering the fallback.
I did so but it does not appear to be working.
My question is how can I configure hystrix to suite my needs.
Here is simple version of what I've came up with so far:
@FeignClient(name="test-client", fallback=TestClientFallback.class)
public interface TestClient
{
//---I have emplemented a custom FeignDecoder to throw TestException
@HystrixCommand(ignoreExceptions=TestException.class)
Boolean isUserActive(Integer userId);
public class TestClientFallback implements TestClient
{
@Override
public Boolean isUserActive(Integer)
{
//---default fail over scenario
}
}
}
Thanks in advance.