Today we share with you the timeout and retry configuration of feign
.
Timeout
The following points need to be noted.
- The connection timeout (connectTimeout) and the read timeout (readTimeout) will take effect when configured at the same time.
- The timeout unit is milliseconds.
- The timeout can be defined individually according to the service name.
For example, if the provider-get
service provides a query interface, the timeout can be set shorter as follows.
The provider-post
service provides the data processing interface, and the timeout can be set longer.
Retries
Implement the feign.Retryer
interface
Understanding of the three parameters.
- period: period, retry interval time
- maxPeriod: maximum period, the retry interval time gradually increases according to certain rules, but cannot exceed the maximum period
- maxAttempts: the maximum number of attempts, the number of retries
After that, we can configure.
Reference https://springboot.io/t/topic/4797