We are sending in instruction sets from a browser into a multi-tier web app using jquery-ajax. The first component (component A, written in C#) validates and persists the instructions into a database, and then calls the second component (component B, written in Java and also called via HTTP) which operates on the instructions after retrieving them from the same database. The browser client just polls the rdbms table via component A after submitting the job, so it is effectively disconnected after sending in the request and doesn't wait for a response from component A.
What is the best way for the middle-tier (component A) to return a success message to the client acknowledging a successful submission of the task, but then still make the request to the task handler (component B) and releasing all of its resources? Returning a response is a final action for the page so we'd have to do something in another thread before sending this back to the browser.
Another option we have considered is for this to happen in component B where the task handler sends back an immediate response to the middle tier acknowledging the request, but then continues on working in the background. The only difference would be where we spawn the additional thread to do the work.
Any good ideas on how to handle this?
What we have done in situations like this is:
STATUS=PENDINGSTATUS=RUNNINGSTATUS=OK or STATUS=ERROR and gives up all resources.The advantage of all that is there is no waiting for the work to finish from you application's point of view. The actual work is done by a "background" thread, just as if you kicked it off with nohup dothework & in a shell. The key is using the DB to monitor the status of the "tracking ID".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With