com.cloudconvert.client.http.AsyncCloseableHttpClientProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudconvert-java Show documentation
Show all versions of cloudconvert-java Show documentation
CloudConvert is an online file converter API - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.
package com.cloudconvert.client.http;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
import org.apache.http.nio.reactor.ConnectingIOReactor;
import java.io.IOException;
public class AsyncCloseableHttpClientProvider extends AbstractCloseableHttpClientProvider {
public AsyncCloseableHttpClientProvider() {
super(DEFAULT_MAX_PER_ROUTE, MAX_TOTAL);
}
public AsyncCloseableHttpClientProvider(final int defaultMaxPerRoute, final int maxTotal) {
super(defaultMaxPerRoute, maxTotal);
}
@Override
public CloseableHttpAsyncClient provide() throws IOException {
final ConnectingIOReactor connectingIOReactor = new DefaultConnectingIOReactor();
final PoolingNHttpClientConnectionManager poolingNHttpClientConnectionManager = new PoolingNHttpClientConnectionManager(connectingIOReactor);
poolingNHttpClientConnectionManager.setDefaultMaxPerRoute(getDefaultMaxPerRoute());
poolingNHttpClientConnectionManager.setMaxTotal(getMaxTotal());
final CloseableHttpAsyncClient closeableHttpAsyncClient = HttpAsyncClientBuilder.create().setConnectionManager(poolingNHttpClientConnectionManager).build();
closeableHttpAsyncClient.start();
return closeableHttpAsyncClient;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy