Java Code Examples for org.springframework.http.client.Netty4ClientHttpRequestFactory#setReadTimeout()
The following examples show how to use
org.springframework.http.client.Netty4ClientHttpRequestFactory#setReadTimeout() .
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: ScmPropertySourceLocator.java From super-cloudops with Apache License 2.0 | 6 votes |
/** * Create rest template. * * @param readTimeout * @return */ public RestTemplate createRestTemplate(long readTimeout) { Assert.state(readTimeout > 0, String.format("Invalid value for read timeout for %s", readTimeout)); Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory(); factory.setConnectTimeout(config.getConnectTimeout()); factory.setReadTimeout((int) readTimeout); factory.setMaxResponseSize(config.getMaxResponseSize()); RestTemplate restTemplate = new RestTemplate(factory); Map<String, String> headers = new HashMap<>(config.getHeaders()); if (headers.containsKey(AUTHORIZATION)) { // To avoid redundant addition of header headers.remove(AUTHORIZATION); } if (!headers.isEmpty()) { restTemplate.setInterceptors(asList(new GenericRequestHeaderInterceptor(headers))); } return restTemplate; }
Example 2
Source File: RestTemplateConfiguration.java From super-cloudops with Apache License 2.0 | 5 votes |
@Bean public ClientHttpRequestFactory netty4ClientHttpRequestFactory() { Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory(); factory.setReadTimeout(5000); factory.setConnectTimeout(5000); factory.setMaxResponseSize(1024 * 1024 * 10); return factory; }
Example 3
Source File: ClientRemoteAutoConfiguration.java From super-cloudops with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean public ClientHttpRequestFactory netty4ClientHttpRequestFactory( RemoteProperties config/* , SslContext sslContext */) { Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory(); factory.setReadTimeout(config.getReadTimeout()); factory.setConnectTimeout(config.getConnectTimeout()); factory.setMaxResponseSize(config.getMaxResponseSize()); // factory.setSslContext(sslContext); return factory; }
Example 4
Source File: AbstractVcsOperator.java From super-cloudops with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() throws Exception { Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory(); factory.setConnectTimeout(config.getVcs().getConnectTimeout()); factory.setReadTimeout(config.getVcs().getReadTimeout()); factory.setMaxResponseSize(config.getVcs().getMaxResponseSize()); this.restTemplate = new RestTemplate(factory); }
Example 5
Source File: AbstractPcmOperator.java From super-cloudops with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() throws Exception { Netty4ClientHttpRequestFactory factory = new Netty4ClientHttpRequestFactory(); factory.setConnectTimeout(config.getPcm().getConnectTimeout()); factory.setReadTimeout(config.getPcm().getReadTimeout()); factory.setMaxResponseSize(config.getPcm().getMaxResponseSize()); this.restTemplate = new RestTemplate(factory); }
Example 6
Source File: ClientHttpRequestFactoryFactory.java From spring-vault with Apache License 2.0 | 5 votes |
static ClientHttpRequestFactory usingNetty(ClientOptions options, SslConfiguration sslConfiguration) throws GeneralSecurityException, IOException { Netty4ClientHttpRequestFactory requestFactory = new Netty4ClientHttpRequestFactory(); if (hasSslConfiguration(sslConfiguration)) { SslContextBuilder sslContextBuilder = SslContextBuilder // .forClient(); if (sslConfiguration.getTrustStoreConfiguration().isPresent()) { sslContextBuilder .trustManager(createTrustManagerFactory(sslConfiguration.getTrustStoreConfiguration())); } if (sslConfiguration.getKeyStoreConfiguration().isPresent()) { sslContextBuilder.keyManager(createKeyManagerFactory(sslConfiguration.getKeyStoreConfiguration(), sslConfiguration.getKeyConfiguration())); } requestFactory.setSslContext(sslContextBuilder.sslProvider(SslProvider.JDK).build()); } requestFactory.setConnectTimeout(Math.toIntExact(options.getConnectionTimeout().toMillis())); requestFactory.setReadTimeout(Math.toIntExact(options.getReadTimeout().toMillis())); return requestFactory; }