How to perform multithreading/background process in classic asp

天涯浪子 提交于 2019-12-10 17:06:39

问题


I need to send emails via a background job on a classic-asp app so the user doesn't have to wait for a slow webserver to complete sending the email.

I know I can use Ajax to generate two separate requests, but I'd rather not require Javascript. Plus, I suspect there's a better way to pull this off. Ideas?


回答1:


You are thinking too narrowly. You don't have to send the email from ASP. Put it into a database and then have a separate program that runs, say, every minute and send all the emails that are in the database.




回答2:


I would agree with tomjen on this one. Saving the email in a database table and then using a back-end process to actually send the email works really well, especially if you are sending large volumes of email. I would recommend Perl for doing the back-end mailer as there are several packages that will easily get the job done.




回答3:


There are 3rd party COM objects you can get that handle mail much better than what is built into IIS. You just pass your message off and it handles the queue so your program gains control back immediately.




回答4:


Persits produces the well-known AspEmail COM component that comes with a mail queuing system that will do what you need.

http://www.aspemail.com/manual_07.html

Your code essentially hands off the sending of the message to a queue daemon that runs on the server and sends whatever mails are in the queue in a separate process, thereby not holding up your ASP script from finishing its execution.




回答5:


Sorry, but as far I as know there were no ways of generating a separate thread using old ASP.

If you don't want AJAX what about a hidden IFRAME? ugly but it works...




回答6:


If you don't want to use my other suggestion, you might want to consider running a different program that just sends email and then communicate with this program through COM or a (local) tcp socket. This should be much faster than having to connect to a server over the internet, and you avoid the delay of using a database.




回答7:


A good way to speed this up would be to instruct CDOSYS to use the IIS pickup directory of your web server (typically c:\inetpub\mailroot\pickup). Assuming your web server has the SMTP Virtual Server installed.

Another similar and yet faster option would be to manually generate *.EML files and put them in the pickup directory. Also to avoid possible conflicts you could put the files in a temporary directory and then have a batch file move them to the pickup directory at certain intervals.



来源:https://stackoverflow.com/questions/952895/how-to-perform-multithreading-background-process-in-classic-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!