Running a GenStage sequence every hour


I am writing an email notification system using GenStage

A : Fetch scheduled notifications from DB (producer) in batches.
B: For each notification, find subscribed users in batches (producer_consumer)
C: For each user, populate an email template with the user’s data + notification data (producer_consumer)
D: For each populated email template, send it off to mail server (consumer)

I’d like to run this sequence from a CRON job every hour. It should keep running until all scheduled notifications in the DB has been handled. Once that is done, it should wait until the next hour

What is the best way to accomplish this?

Hi there,

You can use the quantum library to accomplish this; it features cron-like task scheduling.

Yeah as arjan said you don’t necessarily need gen stage here, at least definitely not for the once per hour bit. If you want to concurrently send stuff to the mail server you could use Flow on the list of people to mail to.