I have my transactional email system setup & by default people get emails as events happen:
class Comment
after_create :email_original_poster
def email_original_poster
UserMailer.delay.notify_author_of_comment self
end
end
However instead of getting the email as-it-happens, a chunk of my users would prefer a daily or weekly digest.
What's the cleanest most elegant way to implement this?
I've already got delayed_job
running but this doesn't really feel like a delayed_job
job since I'm queueing data that needs to be acted on rather than actions that need to be executed.
...without reinventing a queueing system
I know that the obvious solution is table of queued_emails
and of course I could do that. The reason I'm asking the question is that to do so is reinventing a queueing system. Not only are there lots of queuing systems out there but as this well worded post from Percona points out, it's a good idea not to roll your own:
http://www.engineyard.com/blog/2011/5-subtle-ways-youre-using-mysql-as-a-queue-and-why-itll-bite-you/
Have you implemented a digest email, did you use delayed_job
& what did you learn?