Wondering if following flow of events and my potential implementation looks good?

I have a Download button in the UI below a text area. The user is supposed to drop something in the text area and click on the download button.

As soon as the user clicks on the download button, the following things are going to happen:

  1. An ajax call sends some parameters to the REST endpoint.

  2. REST Endpoint triggers a stored procedure(SP1). As soon as SP1 receives a list of parameters, it returns a key (integer ) and a message immediately back (using the out parameter of the stored procedure).

  3. The call to the above stored procedure(SP1) asynchronously launches another stored procedure (let’s say SP2) which is responsible for gathering data based on the parameters received from the SP1 and once its done, it will populate 4 different tables. This stored procedure (SP2) is going to take time.

Based on the key returned from SP1, I can check the status of this stored procedure (SP2) from time to time by querying another table in the database. This will return COMPLETE or RUNNING or ERRONEOUS.

Questions:

  1. So it seems like multiple calls(by multiple calls I mean, user put something in the text area, click on download button, after this user again put some other things in the text area and click on download button; this will call SP1 two times and will trigger two other stored procedures asynchronously) to SP1 would launch multiple stored procedures asynchronously and this is not going to block the user, right? I mean since the SP1 is returning something immediately, it’s not going to tie up the Ajax request forever, right? (Had SP1 was responsible for gathering the data(the job that SP2 is doing above), it would have taken long time and in this case I would have gotten request time out).
    I was wondering do I need to use Java Message Service in this scenario to handle my asynchronous requests? I mean since SP1 is already returning something immediately and other procedure is asynchronously getting launched by calling SP1, I believe I don’t need JMS here, right?

  2. From UI point of view, since I could check the status of the SP2 based on the key returned by SP1, is it a good idea to use heartbeat in javascript to call the web service and check the status at a set interval of time? Or any other alternative that suits best in this scenario?

On the front end, I am just using javascript, jQuery HTML, CSS and back end is RESTFul Java web service…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.