List of usage examples for org.springframework.http.client SimpleClientHttpRequestFactory setReadTimeout
public void setReadTimeout(int readTimeout)
From source file:edu.mayo.cts2.framework.core.client.Cts2RestClient.java
/** * Creates the rest template./*from www .j av a 2 s .c o m*/ * * @param username the username * @param password the password * @return the rest template */ protected RestTemplate createRestTemplate(String username, String password) { RestTemplate restTemplate; if (username != null && password != null) { restTemplate = new FixedRestTemplate(this.createSecureTransport(username, password)); } else { restTemplate = new FixedRestTemplate(); } SimpleClientHttpRequestFactory rf = (SimpleClientHttpRequestFactory) restTemplate.getRequestFactory(); rf.setConnectTimeout(connectTimeoutMS); rf.setReadTimeout(readTimeoutMS); List<HttpMessageConverter<?>> list = new ArrayList<HttpMessageConverter<?>>(); list.add(converter); restTemplate.setMessageConverters(list); return restTemplate; }
From source file:io.github.microcks.service.TestRunnerService.java
/** Retrieve correct test runner according given type. */ private AbstractTestRunner<HttpMethod> retrieveRunner(TestRunnerType runnerType, String serviceId) { // TODO: remove this ugly initialization later. SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); factory.setConnectTimeout(200);/*from w w w. ja v a 2 s. c om*/ factory.setReadTimeout(10000); switch (runnerType) { case SOAP_HTTP: SoapHttpTestRunner soapRunner = new SoapHttpTestRunner(); soapRunner.setClientHttpRequestFactory(factory); soapRunner.setResourceUrl(validationResourceUrl); return soapRunner; case OPEN_API_SCHEMA: OpenAPITestRunner openApiRunner = new OpenAPITestRunner(resourceRepository, responseRepository, false); openApiRunner.setClientHttpRequestFactory(factory); return openApiRunner; case SOAP_UI: // Handle local download of correct project file. List<ImportJob> jobs = jobRepository.findByServiceRefId(serviceId); if (jobs != null && !jobs.isEmpty()) { try { String projectFile = handleRemoteFileDownload(jobs.get(0).getRepositoryUrl()); SoapUITestStepsRunner soapUIRunner = new SoapUITestStepsRunner(projectFile); return soapUIRunner; } catch (IOException ioe) { log.error("IOException while downloading {}", jobs.get(0).getRepositoryUrl()); } } case POSTMAN: // Handle local download of correct project file. jobs = jobRepository.findByServiceRefId(serviceId); if (jobs != null && !jobs.isEmpty()) { try { String collectionFile = handleRemoteFileDownload(jobs.get(0).getRepositoryUrl()); PostmanTestStepsRunner postmanRunner = new PostmanTestStepsRunner(collectionFile); postmanRunner.setClientHttpRequestFactory(factory); postmanRunner.setTestsCallbackUrl(testsCallbackUrl); postmanRunner.setPostmanRunnerUrl(postmanRunnerUrl); return postmanRunner; } catch (IOException ioe) { log.error("IOException while downloading {}", jobs.get(0).getRepositoryUrl()); } } default: HttpTestRunner httpRunner = new HttpTestRunner(); httpRunner.setClientHttpRequestFactory(factory); return httpRunner; } }
From source file:org.zalando.boot.etcd.EtcdClient.java
/** * {@inheritDoc}/* ww w .j a v a 2s . c o m*/ * * @see InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws Exception { if (this.requestFactory == null) { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setConnectTimeout(1000); requestFactory.setReadTimeout(3000); this.requestFactory = requestFactory; } template = new RestTemplate(this.requestFactory); template.setMessageConverters(Arrays.asList(requestConverter, responseConverter)); if (locationUpdaterEnabled) { Runnable worker = new Runnable() { @Override public void run() { updateMembers(); } }; locationUpdater.scheduleAtFixedRate(worker, 5000, 5000, TimeUnit.MILLISECONDS); } }
From source file:org.springframework.boot.actuate.metrics.influxdb.InfluxDBGaugeWriter.java
/** * Creates a new {@code InfluxDBGaugeWriter} with the given millisecond * {@code connectTimeout} and {@code readTimeout}. * * @param connectTimeout the connect timeout in milliseconds * @param readTimeout the read timeout in milliseconds *//*w w w .j a v a 2 s. c o m*/ public InfluxDBGaugeWriter(int connectTimeout, int readTimeout) { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setConnectTimeout(connectTimeout); requestFactory.setReadTimeout(readTimeout); this.restTemplate = new RestTemplate(requestFactory); }
From source file:org.springframework.cloud.config.client.ConfigServicePropertySourceLocator.java
private RestTemplate getSecureRestTemplate(ConfigClientProperties client) { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); requestFactory.setReadTimeout((60 * 1000 * 3) + 5000); //TODO 3m5s, make configurable? RestTemplate template = new RestTemplate(requestFactory); String password = client.getPassword(); if (password != null) { template.setInterceptors(Arrays.<ClientHttpRequestInterceptor>asList( new BasicAuthorizationInterceptor(client.getUsername(), password))); }/*from w w w .j a v a2 s. c om*/ return template; }