4

We have a web application that needs to process a large amount of data and push messages to a series of MSMQueues. This operation is likely to take upwards of 10 minutes but we want a response back (consisting of an ID) quickly. Therefore, we have implemented a system that generates the ID and starts the push process on a separate thread, then returns the ID.

This works fine, but our only concern is when IIS is restarted. We've done some testing and IISRESET kills the worker thread even if our thread hasn't finished queueing messages. Ideally, we'd like to resart IIS in a way where our thread would continue to run until it's finished.

Passing the /NOFORCE switch to IISRESET seems to have no effect.

Does anyone know a way we could ensure that IISRESET waits for our worker thread to complete its processing before restarting IIS.

Thanks,

Steve

2
  • 4
    Is there any way you can offload this process onto another server? I would try to avoid using my webserver for intensive processing. Commented Nov 17, 2009 at 17:27
  • Steve_ - I updated my answer regarding how to pass data to the Windows Service. Commented Nov 18, 2009 at 11:41

2 Answers 2

7

IIS isn't really the place you should be executing long running tasks such as this. We have very similar requirements where we need to initiate long running maintenance tasks on our web servers. These jobs are started via a web service and then handed off to a Windows Service. As long as the Windows service is still alive we can query the tasks for their progress. This means our long running tasks can survive an IISRESET.

IISRESET is pretty much all or nothing and is insensitive to .NET threads you have running in your ASP.NET application.

The /NOFORCE switch is there to tell IISRESET not to forcefully reset IIS if the service doesn't respond within one minute. IISRESET has no knowledge of your .NET applications and will kill your application dead.

Update:

To answer the question in Steve's comment: "How do you recommend passing data to the Windows Service from IIS?". What to do is host a .NET Remoting or WCF application in the windows service and pass data/messages using Named Pipes (only if intra-machine calls are required).

Sign up to request clarification or add additional context in comments.

3 Comments

Completely agree that's exactly how we do it
+1. Also, you might consider switching from MSMQ to Service Broker; there are many advantages in doing so.
Thanks. Using a separate service is something we considered. How do you recommend passing data to the Windows Service from IIS? We thought about writing it to a file but we need to make it as quick as possible.
0

I would suggest that if you do not require a response from the thread which I take it you don't, that you queue it in your db and then create a service to handle the queue. When the re request is made create your unique key and pass it off to the DB to then be picked up by the service. the service can then process the data without you having to worry about your threads being killed and then you can also monitor the traffic/load better with the service as well.

We have a transfer mechanism that works on a similar principle and it make this sort of stuff much simpler in the long run.

If you do need to report back the data then you just have to wait on to the finished report or data is saved to the DB and then the asp.net app can take over the rest.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.