Ank*_*kar 2 java spring-cloud netflix-feign feign spring-cloud-netflix
@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);
}
Run Code Online (Sandbox Code Playgroud)
您可以在所Client使用的特定实现中配置连接数。Feign提供了开箱即用的支持Apache Http,OkHttp并且Ribbon。使用时Spring Cloud Open Feign,默认客户端基于您的类路径中的内容。
这是一个使用的示例Apache Http,您可以CloseableHttpClient使用所需的设置来配置自己的bean。
@Configuration
public class HttpClientConfiguration {
@Bean
public CloseableHttpClient httpClient() {
return HttpClients.custom()
.maxConnectionsPerRoute(200)
.maxConnections(200)
.build()
}
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是Spring Boot,则还可以配置任何feign.httpclient.*属性。
feign:
httpclient:
maxConnections: 200
maxConnectionsPerRoute: 200
Run Code Online (Sandbox Code Playgroud)
您可以在Spring Cloud OpenFeign文档中找到更多信息:覆盖Feign默认值
| 归档时间: |
|
| 查看次数: |
3423 次 |
| 最近记录: |