[英]How to set custom max connection pool size in @feignclient configuration in spring
How to set custom max connection pool size in @feignclient
configuration in spring , 如何在春季的
@feignclient
配置中设置自定义最大连接池大小,
@FeignClient(name = "content-cms", configuration = ContentCmsServiceFeignConfig.class)
public interface FeignService {
@RequestMapping(value = "/test/", method = RequestMethod.GET)
String getSample(@RequestParam("token") String token, @RequestParam("cid") String cid,
@RequestParam("ratio") String ratio, @RequestParam("s") String source);
}
You can configure the number of connections within the specific Client
implementation used. 您可以在所使用的特定
Client
实现中配置连接数。 Feign has out of the box support Apache Http
, OkHttp
and Ribbon
. Feign开箱即用地支持
Apache Http
, OkHttp
和Ribbon
。 When using Spring Cloud Open Feign
, the default client is based on what you have in your classpath. 使用
Spring Cloud Open Feign
,默认客户端基于您的类路径中的内容。
Here is an example using Apache Http
, you can configure your own CloseableHttpClient
bean with the settings you want. 这是一个使用
Apache Http
的示例,您可以使用所需的设置配置自己的CloseableHttpClient
bean。
@Configuration
public class HttpClientConfiguration {
@Bean
public CloseableHttpClient httpClient() {
return HttpClients.custom()
.maxConnectionsPerRoute(200)
.maxConnections(200)
.build()
}
}
If you are using Spring Boot, you can configure any of the feign.httpclient.*
properties as well. 如果您使用的是Spring Boot,则还可以配置任何
feign.httpclient.*
属性。
feign:
httpclient:
maxConnections: 200
maxConnectionsPerRoute: 200
You can find more information in the Spring Cloud OpenFeign Documentation: Overriding Feign Defaults 您可以在Spring Cloud OpenFeign文档中找到更多信息:覆盖Feign默认值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.