Class ApacheHttpAsyncClient4Engine
java.lang.Object
org.jboss.resteasy.client.jaxrs.engines.ApacheHttpAsyncClient4Engine
- All Implemented Interfaces:
Closeable,AutoCloseable,ClientHttpEngine,AsyncClientHttpEngine
@Deprecated(forRemoval=true,
since="6.2")
public class ApacheHttpAsyncClient4Engine
extends Object
implements AsyncClientHttpEngine, Closeable
Deprecated, for removal: This API element is subject to removal in a future version.
AsyncClientHttpEngine using apache http components HttpAsyncClient 4.
Some words of caution:
- Asynchronous IO means non-blocking IO utilizing few threads, typically at most as much threads as number of cores. As such, performance may profit from fewer thread switches and less memory usage due to fewer thread-stacks. But doing synchronous, blocking IO (the invoke-methods not returning a future) may suffer, because the data has to be transferred piecewiese to/from the io-threads.
- Request-Entities are fully buffered in memory, thus this engine is unsuitable for very large uploads.
- Response-Entities are buffered in memory, except if requesting a Response, InputStream or Reader as Result. Thus for large downloads or COMET one of these three return types must be requested, but there may be a performance penalty because the response-body is transferred piecewise from the io-threads. When using InvocationCallbacks, the response is always fully buffered in memory.
- InvocationCallbacks are called from within the io-threads and thus must not block or else the application may slow down to a halt. Reading the response is safe (because the response is buffered in memory), as are other async (and in-memory) Client-invocations (the submit-calls returning a future not containing Response, InputStream or Reader). Again, there must be no blocking IO inside InvocationCallback! (If you are wondering why not to allow blocking calls by wrapping InvocationCallbacks in extra threads: Because then the main advantage of async IO, less threading, is lost.)
- InvocationCallbacks may be called seemingly "after" the future-object returns. Thus, responses should be handled solely in the InvocationCallback.
- InvocationCallbacks will see the same result as the future-object and vice versa. Thus, if the invocationcallback throws an exception, the future-object will not see it. Another reason to handle responses only in the InvocationCallback.
- Author:
- Markus Kull
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.resteasy.client.jaxrs.engines.AsyncClientHttpEngine
AsyncClientHttpEngine.ResultExtractor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.http.impl.nio.client.CloseableHttpAsyncClientDeprecated, for removal: This API element is subject to removal in a future version.protected final booleanDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionApacheHttpAsyncClient4Engine(boolean closeHttpClient) Deprecated, for removal: This API element is subject to removal in a future version.ApacheHttpAsyncClient4Engine(org.apache.http.impl.nio.client.CloseableHttpAsyncClient client, boolean closeHttpClient) Deprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Needed for Client.getHostnameVerifier()Deprecated, for removal: This API element is subject to removal in a future version.Needed for Client.getSslContext();jakarta.ws.rs.core.Responseinvoke(jakarta.ws.rs.client.Invocation request) Deprecated, for removal: This API element is subject to removal in a future version.<T> Future<T> submit(ClientInvocation request, boolean buffered, jakarta.ws.rs.client.InvocationCallback<T> callback, AsyncClientHttpEngine.ResultExtractor<T> extractor) Deprecated, for removal: This API element is subject to removal in a future version.Submits an asynchronous request.<T> CompletableFuture<T> submit(ClientInvocation request, boolean buffered, AsyncClientHttpEngine.ResultExtractor<T> extractor, ExecutorService executorService) Deprecated, for removal: This API element is subject to removal in a future version.Submits an asynchronous request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jboss.resteasy.client.jaxrs.engines.AsyncClientHttpEngine
submitMethods inherited from interface org.jboss.resteasy.client.jaxrs.ClientHttpEngine
isFollowRedirects, setFollowRedirects
-
Field Details
-
client
protected final org.apache.http.impl.nio.client.CloseableHttpAsyncClient clientDeprecated, for removal: This API element is subject to removal in a future version. -
closeHttpClient
protected final boolean closeHttpClientDeprecated, for removal: This API element is subject to removal in a future version.
-
-
Constructor Details
-
ApacheHttpAsyncClient4Engine
public ApacheHttpAsyncClient4Engine(boolean closeHttpClient) Deprecated, for removal: This API element is subject to removal in a future version. -
ApacheHttpAsyncClient4Engine
public ApacheHttpAsyncClient4Engine(org.apache.http.impl.nio.client.CloseableHttpAsyncClient client, boolean closeHttpClient) Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
close
public void close()Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceClientHttpEngine- Specified by:
closein interfaceCloseable
-
getSslContext
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:ClientHttpEngineNeeded for Client.getSslContext();- Specified by:
getSslContextin interfaceClientHttpEngine- Returns:
SSLContext
-
getHostnameVerifier
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:ClientHttpEngineNeeded for Client.getHostnameVerifier()- Specified by:
getHostnameVerifierin interfaceClientHttpEngine- Returns:
HostnameVerifier
-
invoke
public jakarta.ws.rs.core.Response invoke(jakarta.ws.rs.client.Invocation request) Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
invokein interfaceClientHttpEngine
-
submit
public <T> Future<T> submit(ClientInvocation request, boolean buffered, jakarta.ws.rs.client.InvocationCallback<T> callback, AsyncClientHttpEngine.ResultExtractor<T> extractor) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AsyncClientHttpEngineSubmits an asynchronous request.- Specified by:
submitin interfaceAsyncClientHttpEngine- Type Parameters:
T- type- Parameters:
request- Requestbuffered- buffer the response?callback- Optional callback receiving the result, which is run inside the io-thread. may be null.extractor- ResultExtractor for extracting a result out of a ClientResponse. Is run inside the io-thread- Returns:
- Future with the result or Exception
-
submit
public <T> CompletableFuture<T> submit(ClientInvocation request, boolean buffered, AsyncClientHttpEngine.ResultExtractor<T> extractor, ExecutorService executorService) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AsyncClientHttpEngineSubmits an asynchronous request.- Specified by:
submitin interfaceAsyncClientHttpEngine- Type Parameters:
T- type- Parameters:
request- Requestbuffered- buffer the response?extractor- ResultExtractor for extracting a result out of a ClientResponse. Is run inside the io-threadexecutorService- the executor to use for asynchronous execution- Returns:
CompletableFuturewith the result or Exception
-
ClientHttpEnginewill be replaced.