What's the best place to run a reccuring task for a website you host yourself?
In the ASP.Net application I am writing I need to be able to have it send various faxes out. My fax server allows me to send the fax via an HTTP POST and returns to me an ID for the submitted fax.
I need to be able to know if each fax ultimately sends OK or fails for some reason. The fax server allows me to query the status of a fax by using the ID it gave me.
My question is what's the best way to handle this? Should a new thread be created somehow in global.asax? Or should I try and make this a windows service? Or create a recurring job in SQL server that run every now and then?
Everything is in house. Nothing is hosted, so I can pretty much do what I want开发者_Python百科. But I'm unsure what the best way to handle this scenario is.
Any suggestions on an approach?
The ASP.NET application is not a suitable place for a recurring action. IIS can shut down the web application when it's not used, and also it can be recycled at any time.
You can make a windows service, or you can simply make a console application that is started from the windows scheduler. A job in the SQL Server would also work.
I would run a windows service. ASP.NET website does not run consistently.
You could start even simpler and just use a scheduled task to do this if you dont want/need it to run as a service. Fire off the schedule task every 5-15 mins (or whatever you need as a schedule) and have it perform the operations.
Writing this as a Windows Service is what you want if you need to be able to query the status of the service remotely, or if you don't want to worry about a scheduled job hiccuping or not running.
Windows Services are pretty straightforward to write (especially with .NET) and give you all the functionality you need for monitoring and interrogation remotely.
精彩评论