javaspring-boothystrixnetflix-feignspring-cloud-feign

Feign Hystrix fallback not working


I have the below FeignClient:

@FeignClient(name="FooMS",fallback=CustomerFeign.CustomerFeignImpl.class)
public interface CustomerFeign {

    @RequestMapping(value="/bar/{phoneNo}")
    List<Long> getFriends(@PathVariable("phoneNo") Long phoneNo);


    class CustomerFeignImpl implements CustomerFeign{

        @Override
        public List<Long> getFriends(Long phoneNo) {
            return new ArrayList<Long>(108);
        }

    }

}

When the FooMS instance is down, I get a 500 error instead of the fallback being executed. Why is this happening?


Solution

  • Tag your CustomerFeignImpl as a @Component or create a @Bean out of it.