I'm tring to define my fallback function directly in the feign defenition as described in the spring documentation, Please see the code below, but i get an error that i can't define a static class " modifier static not allowed here". How can i get the fallback function to run when feign call fails?
Regards,
Nadav
@FeignClient(name = "hello", fallback = HystrixClientFallback.class)
protected interface HystrixClient {
@RequestMapping(method = RequestMethod.GET, value = "/hello")
Hello iFailSometimes();
}
static class HystrixClientFallback implements HystrixClient {
@Override
public Hello iFailSometimes() {
return new Hello("fallback");
}
}
Adding @Component
to the top of the class worked for me.
@Component
class HystrixClientFallback implements HystrixClient {
@Override
public Hello iFailSometimes() {
return new Hello("fallback");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With