When defining a custom LoadBalancerClient and creating a LoadBalance Bean of type Feign.Builder then its not overriding the DefaultFeignLoadBalancer with our Custom LoadBalancer. It is still looking for Ribbon LoadBalancer. I want to implement Spring Cloud LoadBalancer and that should use in Feign.Builder or normal FeignClient by OpenFeign. The Main reason of doing this, I don't want to use Ribbon Load Balancer while using Feign Client.
@Configuration
@LoadBalancerClient(name = "clientName", configuration = CustomClientConfig.class)
public class CustomLoadBalancerConfig{
@LoadBalanced
@Bean
public Feign.Builder feignBuilder() {
return Feign.builder();
}
}
I have created Feign Interface Manually and has a method which return String type. After that while injecting this feign builder in controller like below, I'm getting issue.
@RestController
public class UserWebController {
private final Feign.Builder feignBuilder;
public UserWebController(Feign.Builder feignBuilder) {
this.feignBuilder = feignBuilder;
}
@GetMapping("/greeting")
public String greet() {
UserFeignClient userFeignClient = feignBuilder.decoder(new StringDecoder()).target(UserFeignClient.class, "http://clientName");
return userFeignClient.greeting();
}
}
When I'm running my application then its started but while calling the endpoint then its throwing exception like below..?
feign.RetryableException: userclient executing GET http://clientName/greeting
at feign.FeignException.errorExecuting(FeignException.java:249) ~[feign-core-10.7.4.jar:na]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ? HTTP GET "/greeting" [ExceptionHandlingWebHandler]
Comment From: Nankh
Hi Team Do you think you could add support between Feign and Spring Cloud Load Balancer ?
Since Ribbon is in maintenance mode, we would like to move forward and use SB Load Balancer instead of Ribon https://cloud.spring.io/spring-cloud-netflix/multi/multi__modules_in_maintenance_mode.html
Regards
Comment From: OlgaMaciaszek
The support for SC LoadBalancer features, including retries has now been added. In order to use it inHoxton, set spring.cloud.loadbalancer.ribbon.enabled to false.