Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 355
codingsplash Avatar asked Dec 21 '25 14:12

codingsplash


2 Answers

adding @Component and feign.hystrix.enabled=true works fine

like image 185
Mahadev Shinde Avatar answered Dec 24 '25 03:12

Mahadev Shinde


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

like image 22
Darren Forsythe Avatar answered Dec 24 '25 04:12

Darren Forsythe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!