1

So I have a restful service which is called by a client. Unfortunately the service is calculation intensive and hence the response goes back to the client after a long time. Is there any way where I can send some dummy response to the client immediately and then later when the calculations are done send the actual data from the server to the client in the form of a server to client request?

  • Not really. Even that thread doesn't have many answers – Anwesh Mohapatra Feb 29 '20 at 12:22
  • That question does seem to answer your question as well. If you don't agree, you should state why the answer(s) to the other question cannot be used in your specific situation. – fishinear Feb 29 '20 at 17:46
  • You can clearly see the below answer provides much more information than that thread. I was looking for polling/web sockets as the possibilities and no one in the thread has mentioned such things. Only below answer by user9123 mentions it. – Anwesh Mohapatra Mar 01 '20 at 02:36
  • Just as a learning point for the next time: if you would have provided that information in the question, then you would have avoided the "Duplicate question" mark. – fishinear Mar 01 '20 at 14:03

1 Answers1

1
  1. via @Async method run your calculation in new thread

  2. while your calculation is running you can send dummy response for your client (you can also add request_id to response for short-polling)

  3. later use short-polling or WebSocket to notify your clients
User9123
  • 1,643
  • 1
  • 8
  • 21