Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion mail queue stops processing

Our CF server occasionally stops processing mail. This is problematic, as many of our clients depend on it.

We found suggestions online that mention zero-byte files in the undeliverable folder, so I created a task that removes them every three minutes. However, the stoppage has occurred again.

I am looking for suggestions for diagnosing and fixing this issue.

  • CF 8 standard
  • Win2k3

Added:

  • There are no errors in the mail log at the time the queue fails
  • We have not tried to run this without using the queue, due to the large amount of mail we send

Added 2:

  • It does not seem to be a problem with any of the files in the spool folder. When we restart the mail queue, they all seem to process correctly.

Added 3:

  • We are not using attachments.
like image 238
Ben Doom Avatar asked Sep 18 '08 17:09

Ben Doom


2 Answers

What we ended up doing:

I wrote two scheduled tasks. The first checked to see if there were any messages in the queue folder older than n minues (currently set to 30). The second reset the queue every night during low usage.

Unfortunately, we never really discovered why the queue would come off the rails, but it only seems to happen when we use Exchange -- other mail servers we've tried do not have this issue.

Edit: I was asked to post my code, so here's the one to restart when old mail is found:

<cfdirectory action="list" directory="c:\coldfusion8\mail\spool\" name="spool" sort="datelastmodified">
<cfset restart = 0>
<cfif datediff('n', spool.datelastmodified, now()) gt 30>
    <cfset restart = 1>
</cfif>
<cfif restart>
    <cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
    <cfset MailSpoolService = sFactory.mailSpoolService>
    <cfset MailSpoolService.stop()>
    <cfset MailSpoolService.start()>
</cfif>
like image 104
Ben Doom Avatar answered Sep 28 '22 18:09

Ben Doom


We have not tried to run this without using the queue, due to the large amount of mail we send

Regardless, have you tried turning off spooling? I've seen mail get sent at a rate of 500-600 messages in a half second, and that's on kind of a crappy server. With the standard page timeout at 60 seconds, that would be ~72,000 emails you could send before the page would time out. Are you sending more than 72,000 at a time?

An alternative I used before CFMail was this fast was to build a custom spooler. Instead of sending the emails on the fly, save them to a database table. Then setup a scheduled job to send a few hundred of the messages and reschedule itself for a few minutes later, until the table is empty.

We scheduled the job to run once a day; and it can re-schedule itself to run again in a couple of minutes if the table isn't empty. Never had a problem with it.

like image 25
Adam Tuttle Avatar answered Sep 28 '22 20:09

Adam Tuttle