The asynchronous processing works on the client side too; JAX-RS APIs are available for it. The following is a simple example of a client using an asynchronous client API:
Client client = newClient();
WebTarget target = client.target(url);
final AsyncInvoker asyncInvoker = target.request().async();
Future<Response> future = asyncInvoker.get();
Response response = future.get();
Unlike synchronous invocation, the asynchronous client calls the HTTP get() method through the javax.ws.rs.client.AsyncInvoker instead of the javax.ws.rs.client.SyncInvoker. The AsyncInvoker returns calling the javax.ws.rs.client.Invocation.Builder.async() method as shown earlier.
The AsyncInvoker provides methods similar to the SyncInvoker, with the difference that these methods do not return a synchronous response. The synchronous responses are replaced by the Future class, shown...