Question: Rails 4 ActionMailer deliver_later method not working if given extended wait period

Question

Rails 4 ActionMailer deliver_later method not working if given extended wait period

Answers 0
Added at 2016-12-02 01:12
Tags
Question

I have a Rails application that is hosted on Heroku that has a feature to send delayed emails.

So the deliver_later! method for ActionMailer is able to send emails asynchronously at a scheduled time.

Basically I have a mailer called NotificationMailer, and when I do

NotificationMailer.send_email(user).deliver_later!(wait_until: 5.minutes.from_now)

or

NotificationMailer.send_email(user).deliver_later!(wait_until: 30.minutes.from_now)

I am able to receive the email 5 minutes from the time it was sent, and 30 minutes from the time it was sent, however when I get more ambitious and do

NotificationMailer.send_email(user).deliver_later!(wait_until: (Time.now.tomorrow.noon - Time.now).seconds.from_now)

Which means I am supposed to receive the next day at noon, but I am unable to receive that email. I looked a lot into this, and I read that Heroku's dynos sleep whenever there's an extended period of inactivity, and then all ActiveJobs in the queue also sleeps. I thought this might be a cause for the problem. I'm not sure how exactly to fix this and would appreciate any suggestions!

Answers
Source Show
◀ Wstecz