My Notebook
by kerner1000
Tell Feign to use Apache’s HTTP client:
public class FeignConfiguration {
@Bean
Client apacheHttpClient(ApacheHttpClientConfigurationProperties properties) {
CloseableHttpClient apacheClient = HttpClients.custom()
.setMaxConnTotal(properties.getMaxConnectionsTotal())
.setMaxConnPerRoute(properties.getMaxConnectionsPerRoute())
.build();
return new ApacheHttpClient(apacheClient);
}
}
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<exclusions>
<exclusion>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
apache:
http:
client:
max-connections-per-route: 20
max-connections-total: 200