org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory Java Examples

The following examples show how to use org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory. 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: ThreadAffinityTest.java    From riptide with MIT License 6 votes vote down vote up
@Test
void syncNonBlockingApache() throws Exception {
    final HttpComponentsAsyncClientHttpRequestFactory requestFactory =
            new HttpComponentsAsyncClientHttpRequestFactory(HttpAsyncClientBuilder.create()
                    .setThreadFactory(threadFactory("io"))
                    .build());

    try {
        final ConfigurationStage stage = Http.builder()
                .asyncRequestFactory(requestFactory);

        test(stage, "main", "io", "io");
    } finally {
        requestFactory.destroy();
    }
}
 
Example #2
Source File: ApplicationAutoConfiguration.java    From opencensus-java with Apache License 2.0 5 votes vote down vote up
/**
 * Factory for AsyncClientHttpRequest.
 *
 * @return AsyncClientHttpRequestFactory
 */
@Bean
public AsyncClientHttpRequestFactory getAsyncClientHttpRequestFactory() {
  int timeout = 5000;
  HttpComponentsAsyncClientHttpRequestFactory asyncClientHttpRequestFactory =
      new HttpComponentsAsyncClientHttpRequestFactory();
  asyncClientHttpRequestFactory.setConnectTimeout(timeout);
  return asyncClientHttpRequestFactory;
}
 
Example #3
Source File: SpringConfig.java    From micro-server with Apache License 2.0 5 votes vote down vote up
@Bean
public NIORestClient restClient(){
	HttpComponentsAsyncClientHttpRequestFactory rest = new HttpComponentsAsyncClientHttpRequestFactory();
	rest.setConnectionRequestTimeout(connectionRequestTimeout);
	rest.setReadTimeout(readTimeout);
	rest.setConnectTimeout(connectTimeout);
	return new NIORestClient(new AsyncRestTemplate(rest));
}
 
Example #4
Source File: ITTracingAsyncClientHttpRequestInterceptor.java    From brave with Apache License 2.0 5 votes vote down vote up
AsyncClientHttpRequestFactory configureClient(AsyncClientHttpRequestInterceptor interceptor) {
  HttpComponentsAsyncClientHttpRequestFactory factory =
    new HttpComponentsAsyncClientHttpRequestFactory(asyncClient);
  factory.setReadTimeout(1000);
  factory.setConnectTimeout(1000);
  this.interceptor = interceptor;
  return factory;
}
 
Example #5
Source File: RestClient.java    From light with Apache License 2.0 4 votes vote down vote up
private AsyncClientHttpRequestFactory asyncHttpRequestFactory() throws Exception {
    return new HttpComponentsAsyncClientHttpRequestFactory(
            asyncHttpClient());
}