This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Apr 19 14:13:07 IST 2019 There was an unexpected error (type=Internal Server Error, status=500). status 401 reading UserFeignClient#getUserByUsername(String) feign.FeignException: status 401 reading UserFeignClient#getUserByUsername(String) at feign.FeignException.errorStatus(FeignException.java:78) at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:93) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:149) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78) at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) at com.sun.proxy.$Proxy214.getUserByUsername(Unknown Source)

service2 to tries to read service1 - getting the above error

1 Answers

0
Esaimozhi Mezhivalavan On

Service1 was down , so Implemented Hystrix with fallback method

@HystrixCommand(fallbackMethod= "fallbackUser", threadPoolKey="itemByUserThreadPool",threadPoolProperties= {@HystrixProperty(name="coreSize",value="30"), @HystrixProperty(name="maxQueueSize",value="10") }) public User getUserByUsername(String username) {

    return userFeignClient.getUserByUsername(username);
}   

//fallback method

private User fallbackUser(String username)
{
    User user =new User();
    user.setId(111L);
    user.setFirstName("TestName");      
    return user;
}