Asynchronous REST

The new features of JAX RS 2.0 are the asynchronous calls.

The processing demands on the server work normally in synchronous mode, which means that the client connection of a request is processed by a single thread made available from a container. Once the thread that processed the request comes back to the container, the container can be safely be assumed that the processing of the request is over and that the client connection can be released safely along with all the resources associated with the connection. This model is generally sufficient to process the requests whose execution of resources to process requires a relatively short time.

However, in cases where the execution of an operation on a resource requires much time to calculate the result, a server-side model of asynchronous processing should be used. In this model, there can be no association between a thread processing the request and a client connection. The container that handles the incoming request can no longer assume a client connection to be closed when it returns a request for processing to the thread.

Instead of exposing a plant, it needs to suspend, reactivate, and close client connections explicitly. Note that the use of the server-side asynchronous processing model will not improve the processing of requests received by the customer's time. However, it will increase the throughput of the server, releasing the initial thread of the container processing demand, while demand can be put in a processing queue or stay running on another dedicated thread. The thread released to the container can be used to accept and process new requests from other connections.

In this chapter, we will cover the following:

  • Calling asynchronous resources through REST
  • Managing timeouts in the REST services
  • Working with callbacks
  • Asynchronous clients
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.17.40