Java Code Examples for org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory

The following examples show how to use org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory. These examples are extracted from open source projects. 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 Project: riptide   Source File: ThreadAffinityTest.java    License: 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
/**
 * Factory for AsyncClientHttpRequest.
 *
 * @return AsyncClientHttpRequestFactory
 */
@Bean
public AsyncClientHttpRequestFactory getAsyncClientHttpRequestFactory() {
  int timeout = 5000;
  HttpComponentsAsyncClientHttpRequestFactory asyncClientHttpRequestFactory =
      new HttpComponentsAsyncClientHttpRequestFactory();
  asyncClientHttpRequestFactory.setConnectTimeout(timeout);
  return asyncClientHttpRequestFactory;
}
 
Example 3
Source Project: micro-server   Source File: SpringConfig.java    License: 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
AsyncClientHttpRequestFactory configureClient(AsyncClientHttpRequestInterceptor interceptor) {
  HttpComponentsAsyncClientHttpRequestFactory factory =
    new HttpComponentsAsyncClientHttpRequestFactory(asyncClient);
  factory.setReadTimeout(1000);
  factory.setConnectTimeout(1000);
  this.interceptor = interceptor;
  return factory;
}
 
Example 5
Source Project: light   Source File: RestClient.java    License: Apache License 2.0 4 votes vote down vote up
private AsyncClientHttpRequestFactory asyncHttpRequestFactory() throws Exception {
    return new HttpComponentsAsyncClientHttpRequestFactory(
            asyncHttpClient());
}