Spring Cloud Load Balance and Feign Client

Viewed 2765

I have been using spring-clound-openfeign with Consul as the service registry and Ribbon as Load Balancer. I am currently working with spring-boot 2.3.10.RELEASE.

I really like spring-cloud-feign-inheritance support which, in my understanding, allows me to write a single interface used by the server side and the client side.

https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html#spring-cloud-feign-inheritance

From spring-boot 2.4.x onward, the spring team recommended replacing Ribbon by spring-clould-loadbanced as a replacement since Ribbon is no longer being maintained.

If I have an interface let say:


interface Greeting {
   @GetMapping
   String hello(String name);
}

By using Spring Openfeign + Ribbon + Consul I could just extend it with:


@FeignClient(name="my-service-id")
interface GreetingClient extends Greeting { }

And with that I would have a client implementation with load balanced capabilities.

Can I still accomplish the same result as spring-cloud-openfeign with spring-clould-loadbalancer or I really need to work with RestTemplate or DiscoveryClient to have the client side of my API?

An over all picture of this would be highly appreciated since nonwhere else I have found a sensible answer.

1 Answers
Related