org.springframework.cloud.openfeign.support.FeignHttpClientProperties Java Examples
The following examples show how to use
org.springframework.cloud.openfeign.support.FeignHttpClientProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestTemplateConfiguration.java From blade-tool with GNU Lesser General Public License v3.0 | 6 votes |
/** * 配置OkHttpClient * @param httpClientFactory httpClient 工厂 * @param connectionPool 链接池配置 * @param httpClientProperties httpClient配置 * @param interceptor 拦截器 * @return OkHttpClient */ @Bean @ConditionalOnMissingBean(okhttp3.OkHttpClient.class) public okhttp3.OkHttpClient httpClient( OkHttpClientFactory httpClientFactory, okhttp3.ConnectionPool connectionPool, FeignHttpClientProperties httpClientProperties, HttpLoggingInterceptor interceptor) { Boolean followRedirects = httpClientProperties.isFollowRedirects(); Integer connectTimeout = httpClientProperties.getConnectionTimeout(); return httpClientFactory.createBuilder(httpClientProperties.isDisableSslValidation()) .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS) .writeTimeout(30, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .followRedirects(followRedirects) .connectionPool(connectionPool) .addInterceptor(interceptor) .build(); }
Example #2
Source File: HttpClientFeignConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty(value = "feign.compression.response.enabled", havingValue = "true") public CloseableHttpClient customHttpClient( HttpClientConnectionManager httpClientConnectionManager, FeignHttpClientProperties httpClientProperties) { HttpClientBuilder builder = HttpClientBuilder.create().disableCookieManagement() .useSystemProperties(); this.httpClient = createClient(builder, httpClientConnectionManager, httpClientProperties); return this.httpClient; }
Example #3
Source File: HttpClientFeignConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnProperty(value = "feign.compression.response.enabled", havingValue = "false", matchIfMissing = true) public CloseableHttpClient httpClient(ApacheHttpClientFactory httpClientFactory, HttpClientConnectionManager httpClientConnectionManager, FeignHttpClientProperties httpClientProperties) { this.httpClient = createClient(httpClientFactory.createBuilder(), httpClientConnectionManager, httpClientProperties); return this.httpClient; }
Example #4
Source File: HttpClientFeignConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
private CloseableHttpClient createClient(HttpClientBuilder builder, HttpClientConnectionManager httpClientConnectionManager, FeignHttpClientProperties httpClientProperties) { RequestConfig defaultRequestConfig = RequestConfig.custom() .setConnectTimeout(httpClientProperties.getConnectionTimeout()) .setRedirectsEnabled(httpClientProperties.isFollowRedirects()).build(); CloseableHttpClient httpClient = builder .setDefaultRequestConfig(defaultRequestConfig) .setConnectionManager(httpClientConnectionManager).build(); return httpClient; }
Example #5
Source File: OkHttpFeignConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(ConnectionPool.class) public ConnectionPool httpClientConnectionPool( FeignHttpClientProperties httpClientProperties, OkHttpClientConnectionPoolFactory connectionPoolFactory) { Integer maxTotalConnections = httpClientProperties.getMaxConnections(); Long timeToLive = httpClientProperties.getTimeToLive(); TimeUnit ttlUnit = httpClientProperties.getTimeToLiveUnit(); return connectionPoolFactory.create(maxTotalConnections, timeToLive, ttlUnit); }
Example #6
Source File: OkHttpFeignConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean public okhttp3.OkHttpClient client(OkHttpClientFactory httpClientFactory, ConnectionPool connectionPool, FeignHttpClientProperties httpClientProperties) { Boolean followRedirects = httpClientProperties.isFollowRedirects(); Integer connectTimeout = httpClientProperties.getConnectionTimeout(); this.okHttpClient = httpClientFactory .createBuilder(httpClientProperties.isDisableSslValidation()) .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS) .followRedirects(followRedirects).connectionPool(connectionPool).build(); return this.okHttpClient; }
Example #7
Source File: FeignAutoConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean public CloseableHttpClient httpClient(ApacheHttpClientFactory httpClientFactory, HttpClientConnectionManager httpClientConnectionManager, FeignHttpClientProperties httpClientProperties) { RequestConfig defaultRequestConfig = RequestConfig.custom() .setConnectTimeout(httpClientProperties.getConnectionTimeout()) .setRedirectsEnabled(httpClientProperties.isFollowRedirects()) .build(); this.httpClient = httpClientFactory.createBuilder() .setConnectionManager(httpClientConnectionManager) .setDefaultRequestConfig(defaultRequestConfig).build(); return this.httpClient; }
Example #8
Source File: FeignAutoConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(ConnectionPool.class) public ConnectionPool httpClientConnectionPool( FeignHttpClientProperties httpClientProperties, OkHttpClientConnectionPoolFactory connectionPoolFactory) { Integer maxTotalConnections = httpClientProperties.getMaxConnections(); Long timeToLive = httpClientProperties.getTimeToLive(); TimeUnit ttlUnit = httpClientProperties.getTimeToLiveUnit(); return connectionPoolFactory.create(maxTotalConnections, timeToLive, ttlUnit); }
Example #9
Source File: FeignAutoConfiguration.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Bean public okhttp3.OkHttpClient client(OkHttpClientFactory httpClientFactory, ConnectionPool connectionPool, FeignHttpClientProperties httpClientProperties) { Boolean followRedirects = httpClientProperties.isFollowRedirects(); Integer connectTimeout = httpClientProperties.getConnectionTimeout(); Boolean disableSslValidation = httpClientProperties.isDisableSslValidation(); this.okHttpClient = httpClientFactory.createBuilder(disableSslValidation) .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS) .followRedirects(followRedirects).connectionPool(connectionPool) .build(); return this.okHttpClient; }
Example #10
Source File: RestTemplateConfiguration.java From blade-tool with GNU Lesser General Public License v3.0 | 5 votes |
/** * okhttp3 链接池配置 * @param connectionPoolFactory 链接池配置 * @param httpClientProperties httpClient配置 * @return okhttp3.ConnectionPool */ @Bean @ConditionalOnMissingBean(okhttp3.ConnectionPool.class) public okhttp3.ConnectionPool httpClientConnectionPool( FeignHttpClientProperties httpClientProperties, OkHttpClientConnectionPoolFactory connectionPoolFactory) { Integer maxTotalConnections = httpClientProperties.getMaxConnections(); Long timeToLive = httpClientProperties.getTimeToLive(); TimeUnit ttlUnit = httpClientProperties.getTimeToLiveUnit(); return connectionPoolFactory.create(maxTotalConnections, timeToLive, ttlUnit); }