Author |
|
christian Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 29 March 2006 at 5:46pm | IP Logged
|
|
|
hello,
we're using message queue to send approximately 25,000 emails from a web based form. in our testing it seems that the browser sits and waits for all the messages to be send to the queue before moving the the "sent" page. is there a way to avoid this so that the queue just fires in the background? we're having issues with the browser hanging.
thanks.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 30 March 2006 at 12:24pm | IP Logged
|
|
|
Actually, composing of 25.000 mail messages can take much longer time than submitting them to Message Queue (which is just a save file operation).
Since all mail messages are composed by your application (not by Message Queue), you can reduce the response time of your ASP script by developing the background implementation of this process.
However, if the main goal is just to avoid hanging browser for a period of submitting messages to Message Queue, the solution is to indicate the progress of message submitting process to the user.
You can use the Response.Write and Response.Flush methods for this proposes to display notification and send the output to the client.
For instance, if you're submitting 25.000 messages from database, you can use the code like below:
Code:
I = 0
While Not rsUsers.EOF
' Prepare the message (omitted). This step takes the most time
' and cannot be performed by Message Queue because it does not know
' how to compose your messages.
...
' Submit to MessageQueue
SMTP.SendTOQueue
I = I + 1
If I = 1000 Then
Response.Write "1000 messages submitted"
Response.Flush
I = 0
End If
.rsUsers.MoveNext
Wend
|
|
|
Also, please make sure you're using SMTP.SendToQueue method instead of SMTP.Send method.
Besides that, check up your code for calls of SMTP.Connect and SMTP.Disconnect methods, because they are useless when calling SMTP.SendToQueue method. If they are there, this can also cause extra delays in submitting messages to Message Queue.
Regards,
Alex
|
Back to Top |
|
|
christian Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 31 March 2006 at 11:11pm | IP Logged
|
|
|
Thanks alex. The progress text will help.
It seems that it's this line that slows things up:
objSMTP.SendToQueueEx "C:\MMQ", strBounceEmail
When that is commented out, the 24K emails are processed instantly....of course, commenting that line essentially stops any emails from ever being sent!!
|
Back to Top |
|
|
christian Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 31 March 2006 at 11:15pm | IP Logged
|
|
|
FYI -- here is the abbreviated code
Set objSMTP = Server.CreateObject("MailBee.SMTP")
' Set HTML format for body
objSMTP.BodyFormat = 1
' Enable logging SMTP session into a file. If 'any errors occur, the log can be used to 'investigate the problem.
objSMTP.EnableLogging = True
objSMTP.LogFilePath = "C:\mmq_log.txt"
objSMTP.ClearLog
' Specify "From:" and "Subject:". They remain unchanged
' for all the e-mails. This is the visual from only the actual sending address is specified below (for bouncebacks)
objSMTP.Message.FromAddr = strFromEmail
objSMTP.Message.Subject = strSubject
objSMTP.Message.BodyText = strHTMLBody
' Set plain-text body
objSMTP.Message.AltBodyText = strTextBody
'If the list of subscribers is populated
If Ubound(arrSubscribers,2) >= 0 Then
'Loop through all the subscribers
For i = 0 to Ubound(arrSubscribers,2)
objSMTP.ToAddr = arrSubscribers(3,i)
objSMTP.SendToQueueEx "C:\MMQ", strBounceEmail
Next
End If
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 01 April 2006 at 5:35am | IP Logged
|
|
|
Quote:
It seems that it's this line that slows things up:
objSMTP.SendToQueueEx "C:\MMQ", strBounceEmail
|
|
|
Yes, this line composes a message and then puts it into the queue. BTW, how much time (in seconds) does it take to submit 25K mails to the queue on your system?
Regards,
Alex
|
Back to Top |
|
|
christian Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 01 April 2006 at 10:50am | IP Logged
|
|
|
it's taking too long! I finally was able to generate an error message:
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration
tools. (or HTTP 500 Internal Server Error)
I currently have the Server.Timeout method set to 4000....although from what I've read, the actual limit seems to be 999....any ideas on how to resolve this?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 01 April 2006 at 11:34am | IP Logged
|
|
|
That's unusually slow.. I just tested sending 25K mails (10Kb each) on not very fast machine (1.5Ghz, 256MB RAM, 4200RPM notebook HDD), and it took only 170 seconds. Maybe, there is CPU limit set for the app (such as 10%), or there are too many files already in queue folder? I started with empty folder, but if you already have hundreds thousands mails there, this may slow down file I/O too.
You may also disable logging of SMTP object (this log does not contain useful information anyway since SMTP object just submits files to MessageQueue in your case, while MessageQueue's own log will contain actual status of sending messages).
As for how to let ASP script (mail.asp) execute longer, you can call it multiple times:
Code:
N = Request("n")
I = 0
Response.Write N & " messages submitted<br>"
Response.Flush
While Not rsUsers.EOF
If I >= N Then
' Compose message
' Submit to MessageQueue
' ...
SMTP.SendTOQueue
End If
I = I + 1
If I = N + 1000 Then
Exit For
End If
.rsUsers.MoveNext
Wend
If .rsUsers.EOF
Response.Write "Done<br>"
Else
Response.Write "<script>window.location.replace('mail.asp?n=" & I & "');</script>"
End If
|
|
|
Regards,
Alex
|
Back to Top |
|
|
christian Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 01 April 2006 at 8:13pm | IP Logged
|
|
|
It's an Intel Xeon 2,8Ghz w/ 2GB Ram and a very fast hardrive. I setup perfmon conunters and the cpu is tracking at 100% during the operation. Each email is 15KB.
|
Back to Top |
|
|
christian Guest Group
Joined: 10 November 2003
Online Status: Online Posts: 262
|
Posted: 01 April 2006 at 8:16pm | IP Logged
|
|
|
Also- the queue folder has been cleared out before running each time.
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 02 April 2006 at 9:02am | IP Logged
|
|
|
I tested with 16K mails now (and logging enabled). It's 230 seconds. Could you try to save the code into .VBS file (CreateObject instead of Server.CreateObject and remove web stuff like Response, etc), and run it directly on the server?
How much does it take when the script is executed under Windows, not under ASP/IIS?
Code:
T = Now
... mailing goes here
MsgBox "Finished in " & DateDiff("s", T, Now) & " secs"
|
|
|
Regards,
Alex
|
Back to Top |
|
|