1

I want to use AsyncRestTemplate for making a REST call in my service. According to Spring documentation, this class has 5 constructors( refer http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/AsyncRestTemplate.html)

AsyncRestTemplate(AsyncClientHttpRequestFactory asyncRequestFactory)-Using this AsyncClientHttpRequestFactory argument I will be able to configure the connection pool.

AsyncRestTemplate(AsyncListenableTaskExecutor taskExecutor)-Using this I will be able to configure the thread pool for the async operation.

I want to know if there is a way I could configure both connection pool and thread pool in AsyncRestTemplate.

Thank you very much in adance.

user3740951
  • 1,109
  • 2
  • 20
  • 39

1 Answers1

2

You can set task executor in SimpleClientHttpRequestFactory also:

    ThreadPoolTaskScheduler taskExecutor = new ThreadPoolTaskScheduler();
    taskExecutor.setPoolSize(10);
    SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = new SimpleClientHttpRequestFactory();
    simpleClientHttpRequestFactory.setTaskExecutor(taskExecutor);
    new AsyncRestTemplate(simpleClientHttpRequestFactory);
ThomasRS
  • 8,215
  • 5
  • 33
  • 48
Abhilekh Singh
  • 2,845
  • 2
  • 18
  • 24