• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Scheduled Task and sending emails in batches

Guide ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

I'm working with an application that uses a recurring scheduled task to forward internal messages to a user's email account, etc. Messages are forwarded every 60 minutes or so.

Right now the scheduled task processes all of the messages at once. I want to break it up into batches. In other words, send x number of messages .. wait ... send the next x messages... until all of the messages are processed.

Any ideas how this might be done or better suggestions?
TOPICS
Advanced techniques

Views

738

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

Well, you could merely sleep() in between batches but then you'd have to make sure the whole page call did not time out.

Here's the approach I would use:

  1. The main task uses cfschedule to create a new task that runs every X minutes.
  2. The sub task fetches the next batch of emails from a database and sends them.
  3. The sub task deletes the sent emails from the DB queue, or marks them as sent, or logs any errors.
  4. If the sub task finds no messages waiting to be sent, it uses cfschedule to delete itself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

That sounds like a good approach. Unfortunately the application is running on MX 6.1 so I ran into this isssue

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_18361
ColdFusion MX: Deleted scheduled tasks continue to run

I found a few blog entries with possible workarounds. I'm still researching ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

Then use the service factory to delete the task.
Or, if you don't want to pay to upgrade to CF7, perhaps switch to a different platform...

We found long ago that it payed to upgrade.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

I agree, but its not under my control. An upgrade is planned in the near future, but for right now I'm stuck with MX 6.1.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

Then use the service factory or just have one task that fires every X minutes and either sends only the batch count or quits.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

Thanks. I'll try your two suggestions and see what works best. My preference would be to avoid service factory, because its undocumented. But if it ends up being the only thing that works ... I'll use it. I'm also looking at similar entries here

http://www.schierberl.com/cfblog/index.cfm/2006/8/18/cfschedule-delete-workaround
http://www.bennadel.com/index.cfm?dax=blog:356.view

I checked the online documentation for MX 7 and one of the comments suggests the issue also exists with MX 7. Do you know if thats true?

frinky!!! said on Mar 15, 2005 at 3:51 PM :
Unfortunately, this problem: http://www.macromedia.com/go/tn_18361 has not been solved with MX7.0, even though the problem exists since MX6.0. Can you, Macromedia, please put it on your RFC list?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 29, 2006 Oct 29, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: cf_dev2
...
I checked the online documentation for MX 7 and one of the comments suggests the issue also exists with MX 7. Do you know if thats true?

The problem has definitely been resolved with CF 7.

Our servers use cfschedule deletes continually with no problems. (We're running 7.01 and 7.02 but I don't remember a problem with 7.0 either. (We used a non-cfschedule approach to our problem with CF 6, CF 7 solved the problem so much better.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 30, 2006 Oct 30, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: MikerRoo
The problem has definitely been resolved with CF 7.



Ok.. I'm officially confused. I did a few tests with MX 7.0.1/Developer Edition. The results are the same as with 6.1. The scheduled task is deleted but continues to run.

My test task appends a single line to a log file. The task continues to write to the log file even after it is deleted. Can you post a small example that is working for you?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 30, 2006 Oct 30, 2006

Copy link to clipboard

Copied

Our code is embedded in a CFC system.
When I started to distill it down to an example for you, I remembered/saw that we ARE using a workaround**.
(These never-resolved CF bugs are really starting to annoy me.)

Anyway, attached is a boiled down application that shows the details.



** That's the beauty of CFC's: Write em, Test em, Forget the details and just use em. ;-)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 31, 2006 Oct 31, 2006

Copy link to clipboard

Copied

LATEST
Thanks so much. It looks like a great example. I'll test it out tomorrow when I have access to both MX6 and 7 .. and I've put out todays fires...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation