Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP/Microsoft.XMLHTTP asynchronous request

Status
Not open for further replies.

logx

Technical User
Jul 24, 2006
14
RS
Hi,

I have a script which takes ~20 minutes to fully process and it runs in the background. I want to be able to run multiple instances of this script at the same time, all initiated manually through a webpage.

I use Microsoft.XMLHTTP to send an asynchronous request, however once the first request is sent, when I try to initiate another one it won't kick in until the first has completed (it queues up).

Here is the code I am using to achieve this:

---
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST", " & LAUNCH_ID, true

xmlhttp.setRequestHeader "Content-Type", "application/x-xmlhttp.send

Set xmlhttp=Nothing
response.redirect "index.asp"
---

When the user is redirected to index.asp, they should be able to add new variables, fire up a new request and have the script start processing in the background again. However, if they do, the script would start processing only after the previous one has finished.

I am open to suggestions/workaround on how this can be achieved.

Thanks!
 
Mmmmmm, my initial thought is: 20 minutes processing??!!! if your script does database operations: use a stored procedure. Most likely that will speed up things.
Besides that: with programs like this there will be a maximum number of simultaneous jobs (performance wise).
I would store every user request into a table (id, action, launch_id, jobstatus). Then an trigger is set on that table:
if number of records with jobstatus = 1 (running) > x then: nothing (maximum number of jobs in the system)
else pick the first record with jobstatus = 0 and launch a processing job.
The processing job would end with updating the jobstatus eg into 2 (job ended). That would fire the trigger again.
That job table is also a way to inform your end-users (you could provide more detailed status info. and of course a job could fail).






 
Hi,

Thank for replying. Maybe I should have added few extra details.

The script uses, among other things, psexec in order to execute certain set of commands on Windows based machines.

I like the idea you have proposed, but that would mean I would need to trigger this script through other means and not via web-browser accessible by the end-user, correct? As I would end up using the same type of request (async Microsoft.XMLHTTP) which would then want to queue up.

Ideally, if I could somehow make multiple requests through async Microsoft.XMLHTTP kick off at the same time, that would be excellent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top