I have a design problem to solve where my application is developed using Spring
.
There is a REST API
which have to be designed in the following way.
Process request and call an external web service and get the results.
Start processing -> Call External Web Service in async way. External service will inform main request once completes if main request is still alive. -> Continue to process main request. -> Check if async process completes in next 100millisec -> If results arrived, return Status 201 with new URI to get complete results. -> If external service is not complete, return Client with Status 202 asking client to call back after some time.
I am thinking on how to achieve this solution.
I know we might have many solutions. But can I have some good approach/suggestions in achieving this? Not very detailed.
Please let me know if you need any more details on this if it is not clear.
More updates: Main thread calls this web service in a new thread. New thread once completes its processing, informs main thread if alive. Otherwise just updates data in db.