@Contract(threading=SAFE_CONDITIONAL) public class FutureRequestExecutionService extends Object implements Closeable
FutureTasks with the provided ExecutorService.| Constructor and Description |
|---|
FutureRequestExecutionService(HttpClient httpclient,
ExecutorService executorService)
Create a new FutureRequestExecutionService.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this stream and releases any system resources associated with it.
|
<T> java.util.concurrent.FutureTask<T> |
execute(ClassicHttpRequest request,
HttpContext context,
HttpClientResponseHandler<T> HttpClientResponseHandler)
Schedule a request for execution.
|
<T> java.util.concurrent.FutureTask<T> |
execute(ClassicHttpRequest request,
HttpContext context,
HttpClientResponseHandler<T> HttpClientResponseHandler,
FutureCallback<T> callback)
Schedule a request for execution.
|
FutureRequestExecutionMetrics |
metrics() |
public FutureRequestExecutionService(HttpClient httpclient, ExecutorService executorService)
httpclient - you should tune your httpclient instance to match your needs. You should
align the max number of connections in the pool and the number of threads
in the executor; it doesn't make sense to have more threads than connections
and if you have less connections than threads, the threads will just end up
blocking on getting a connection from the pool.executorService - any executorService will do here. E.g.
Executors.newFixedThreadPool(int)public void close()
throws IOException
Closeableclose in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occurspublic <T> java.util.concurrent.FutureTask<T> execute(ClassicHttpRequest request, HttpContext context, HttpClientResponseHandler<T> HttpClientResponseHandler)
T - request - request to executeHttpClientResponseHandler - handler that will process the response.public <T> java.util.concurrent.FutureTask<T> execute(ClassicHttpRequest request, HttpContext context, HttpClientResponseHandler<T> HttpClientResponseHandler, FutureCallback<T> callback)
T - request - request to executecontext - optional context; use null if not needed.HttpClientResponseHandler - handler that will process the response.callback - callback handler that will be called when the request is scheduled,
started, completed, failed, or cancelled.public FutureRequestExecutionMetrics metrics()
FutureRequestExecutionMetrics