Greetings!
In my previous post I introduced Feign REST client with hard coded (or single) URL. We can improve it using Ribbon.
Ribbon is a client side load balancer which not only provides load balancing feature but also support caching, fault tolerance.
Source code can be found at github.
Restart the cart service and test the application. Remember to push the configuration changes to github.
https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html
In my previous post I introduced Feign REST client with hard coded (or single) URL. We can improve it using Ribbon.
Ribbon is a client side load balancer which not only provides load balancing feature but also support caching, fault tolerance.
Source code can be found at github.
Add Ribbon library
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
Update properties
Update cart-service.yml
catalog-service:
ribbon:
listOfServers: localhost:8010,localhost:8011
Update Fiegn Client
@FeignClient(name = "catalog-service")
@RibbonClient(name = "catalog-service")
public interface CatalogServiceFeign
Restart the cart service and test the application. Remember to push the configuration changes to github.
References
https://github.com/Netflix/ribbonhttps://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html
Comments
Post a Comment