because Spring Cloud Feign client-side load balancing is through Spring Cloud Ribbon implemented, so we can directly configure the Ribbon client to customize the parameters of each service client invocation.
Global configuration
the method of global configuration is very simple, we can use it directly Ribbon.<key>=<value> to set the ribbon 's default parameters, for example, Modify the default client call timeout example below, using the yml format configuration:
Ribbon
ConnectionTimeout:
ReadTimeout:
Specify the configuration of the service
Most of the cases, Our time-out for service calls may be adjusted based on the characteristics of the actual service, so it is not possible to rely solely on the default configuration, using the spring cloud feign When personalized for each service client and using the spring cloud ribbon < client> for use @feignclient annotated name property or the service name specified by the value attribute, which needs to be case-sensitive, as shown in the following example:
ORG. Lixue. HELLOWORLD:
Ribbon
ConnectionTimeout:
ReadTimeout:
Common Ribbon Configurations
&NBSP;
configuration name |
|
|
connectiontimeout |
&NBSP; |
connection time-out |
readtimeout | TD style= "PADDING-TOP:5PX; padding-left:5px; padding-bottom:5px; padding-right:5px; Border-top:none; Border-left:none; Border-bottom:solid #a3a3a3 1.0pt; Border-right:solid #a3a3a3 1.0pt ">
read timeout |
oktoretryonalloperatotions |
&NBSP; |
retry all operation requests |
maxautoretriesnextserver |
&NBSP; |
switch server instance retry attempts, |
maxautoretries |
&NBSP; |
retry attempts on the current instance |
Serverlistrefreshinterval |
|
Time interval for refreshing service list sources |
NOTES: Spring Cloud feign Ribbon configuration