ASYNCHRONOUS RESTful web service |
Web Services |
The request processing in PROIV works by default in a synchronous processing mode, which means when you invoke a web service, the invoking client application waits for the response to return before it can continue with its work. This model is typically sufficient for processing of requests for which the processing resource method execution takes a relatively short time. However, in cases where a service execution is known to take a long time to compute the result, server-side asynchronous processing model may be used. This helps the client application to continue its work and handle the response later on.
In the Asynchronous model, the association between a service request processing thread and the PROIV kernel task is broken. Asynchronous REST services will start a new thread to access the PROIV Kernel and return a 202 (Accepted) response status immediately. The PROIV kernel processing thread continues in the same way as it does for synchronous REST services. To identify an Asynchronous REST service, the REST server looks for the request header property called ‘Operation-Type’ and if it has the value of ‘async’ then the service will be processed asynchronously. Any other values will cause the service to be processed synchronously. If the header is not present, then the service will be processed synchronously.
After an Asynchronous service has started, the client can poll the server sending requests to ask for the status of the service. The returned response status will be 200 (OK) and the data status will be ‘In Progress’ until the service is complete. When the service is complete the returned response status will be 303 and the response header will contain a URL that will return the service result.
There is no change in the definition of a PROIV REST service in order to run a service asynchronously. All currently defined REST services can be run synchronously or asynchronously.
The following section step through synchronous and asynchronous message flow diagrams:
Process flow for Synchronous REST web service request
Process flow for Asynchronous REST web service request
Topic ID: 400045