Jon
Jon

Reputation: 179

Rails: Sending scheduled emails

I'm using the "resque" gem along with "resque-scheduler". I have to send out 10,000+ emails a week (about 1,500 a day). My email table has a boolean called "sent" (true/false).

Would it be best if I use the "enqueue_at" method & just have a bunch of queued emails (not sure if they literally get queued in resque.. maybe someone can clarify this) Or would it be better if I do a cron type task and just run down all the emails where the "sent" boolean is "false" & update it to "true" after the emails are sent?

Which would be the best solution & why?

Thanks in advance

Upvotes: 1

Views: 675

Answers (1)

Pierre-Louis Gottfrois
Pierre-Louis Gottfrois

Reputation: 17631

Using a cron

  • Automatically pull out unsent emails and mark them as "sent"
  • Only check emails every X time (the time you set in your cron file)

Using enqueue_at

  • You have to explicitely tell the job to fire in X time (Resque.enqueue_at(5.days.from_now, SomeJob))

I would do a cron task using resque-scheduler and select only unsent emails in my worker to process them and finally mark them as sent.

Upvotes: 2

Related Questions