use of org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method restartWithKeepAlive.
@Test
public void restartWithKeepAlive() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
HttpComponentsAsyncClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsAsyncClientHttpRequestFactory();
ListenableFuture<ClientHttpResponse> response1 = clientHttpRequestFactory.createAsyncRequest(new URI(getLocalUrl("/hello")), HttpMethod.GET).executeAsync();
assertThat(response1.get(10, TimeUnit.SECONDS).getRawStatusCode()).isEqualTo(200);
this.webServer.stop();
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
ListenableFuture<ClientHttpResponse> response2 = clientHttpRequestFactory.createAsyncRequest(new URI(getLocalUrl("/hello")), HttpMethod.GET).executeAsync();
assertThat(response2.get(10, TimeUnit.SECONDS).getRawStatusCode()).isEqualTo(200);
clientHttpRequestFactory.destroy();
}
use of org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory in project brave by openzipkin.
the class ITTracingAsyncClientHttpRequestInterceptor method configureClient.
AsyncClientHttpRequestFactory configureClient(AsyncClientHttpRequestInterceptor interceptor) {
HttpComponentsAsyncClientHttpRequestFactory factory = new HttpComponentsAsyncClientHttpRequestFactory();
factory.setReadTimeout(1000);
factory.setConnectTimeout(1000);
this.interceptor = interceptor;
return factory;
}
use of org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory in project instrumentation-java by census-instrumentation.
the class ApplicationAutoConfiguration method getAsyncClientHttpRequestFactory.
/**
* Factory for AsyncClientHttpRequest.
*
* @return AsyncClientHttpRequestFactory
*/
@Bean
public AsyncClientHttpRequestFactory getAsyncClientHttpRequestFactory() {
int timeout = 5000;
HttpComponentsAsyncClientHttpRequestFactory asyncClientHttpRequestFactory = new HttpComponentsAsyncClientHttpRequestFactory();
asyncClientHttpRequestFactory.setConnectTimeout(timeout);
return asyncClientHttpRequestFactory;
}
Aggregations