microservices
Feign Client and Fallbacks.
Feign Client:
A declarative REST client that makes writing web service clients easier.
@FeignClient(name = "user-service", fallback = UserServiceFallback.class) public interface UserClient { @GetMapping("/users/{id}") User getUser(@PathVariable String id); }
Fallbacks:
- Part of resilience. If
user-serviceis down, the code insideUserServiceFallbackwill execute instead of throwing an error. - Provides a "Graceful Degradation" experience for the user.