The ribbon is a client load balancer that provides good control over the behavior of HTTP and TCP clients. feign already uses the Ribbon, so if you use it @FeignClient
, this section also applies.
the central concept in the Ribbon is the concept of a specified client. Each load balancer is part of a combination of combinations that work together to contact a remote server as needed, and the collection has a name that you use as an application developer, such as a @FeignClient
comment. Spring Cloud uses RibbonClientConfiguration
a new ensemble as needed for each named client to create ApplicationContext
. This contains (among other things) ILoadBalancer
, RestClient
and ServerListFilter
.
to include the Ribbon in your project, use org.springframework.cloud
the starter for group and artifact IDs spring-cloud-starter-ribbon
. for More information about using the current Spring Cloud Publishing list settings to build your system, see The Spring Cloud project page .
Customizing the Ribbon client
You can use <client>.ribbon.*
the external properties in to configure some bits of the Ribbon client, which is not the same as using the Netflix API itself, but only with the spring boot configuration file. native options can be CommonClientConfigKey
checked as static fields (in the core section of the Ribbon).
Spring Cloud also allows you @RibbonClient
to fully control the client by using the claim other configuration (on RibbonClientConfiguration
top). Example:
@Configuration@RibbonClient(name = "foo", configuration = FooConfiguration.class)public class TestConfiguration {}
In this case, the client consists of a RibbonClientConfiguration
component that already exists in it and FooConfiguration
any of the components in it (the latter will usually overwrite the former).
More information and source source
Learn from me Spring cloud-client load balancer: Ribbon