8π
β
Weβre doing something like this in the company i work for, and the solution is quite simple.
Have a cron / celery beat that runs every hour to check if any notification needs to be sent.
Then send those notifications and mark them as done. This way, even if your notification time is years ahead, it will still be sent. Using ETA is NOT the way to go for a very long wait time, your cache / amqp might loose the data.
You can reduce your interval depending on your needs, but do make sure they dont overlap.
If one hour is too huge of a time difference, then what you can do is, run a scheduler every hour. Logic would be something like
- run a task (lets call this scheduler task) hourly that gets all notifications that needs to be sent in the next hour (via celery beat) β
- Schedule those notifications via apply_async(eta) β this will be the actual sending
Using that methodology would get you both of best worlds (eta and beat)
π€ibaguio
Source:stackexchange.com