线程数

编辑

Apache Http Async Client 默认情况下启动一个调度线程,以及连接管理器使用的多个工作线程,其数量与本地检测到的处理器数量相同(取决于Runtime.getRuntime().availableProcessors() 的返回值)。线程数可以按如下方式修改:

RestClientBuilder builder = RestClient.builder(
    new HttpHost("localhost", 9200))
    .setHttpClientConfigCallback(new HttpClientConfigCallback() {
        @Override
        public HttpAsyncClientBuilder customizeHttpClient(
                HttpAsyncClientBuilder httpClientBuilder) {
            return httpClientBuilder.setDefaultIOReactorConfig(
                IOReactorConfig.custom()
                    .setIoThreadCount(1)
                    .build());
        }
    });