简体   繁体   English

春天如何在@feignclient配置中设置自定义最大连接池大小

[英]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 HttpOkHttpRibbon 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.

相关问题 如何设置SQL Server连接池大小 - How to set SQL Server Connection pool size 在MongoDB + Java中定义最大连接池大小 - Define Max connection pool size in MongoDB + Java 如何通过Spring应用程序处理EntityManger建立的连接池大小 - How to handle Connection pool size established by EntityManger through a Spring Application Spring Boot连接池配置的最佳实践 - Best practices for Spring Boot connection pool configuration SpringBoot如何为Hikari Pool和jdbcTemplate设置连接获取大小 - SpringBoot how to set connection fetch size for Hikari Pool and jdbcTemplate 如何在Spring中将tomcat连接池属性添加到自定义数据源中? - How to add tomcat connection pool properties to custom DataSource in Spring? "如何在 Spring Webflux \/ WebClient 中设置事件循环池大小?" - How to set event-loop pool size in Spring Webflux / WebClient? 在Spring Boot应用程序中创建自定义连接池 - Creating custom connection pool in Spring Boot application 如何在Spring Boot中使用自定义前缀配置数据库配置连接池? - How to configure database configuration connection pooling with custom prefix in Spring Boot? Spring Boot 2具有tomcat连接池和oracle数据源配置? - Spring Boot 2 with tomcat connection pool and oracle datasource configuration?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM