Execute Delayed jobs in elixir

The app I am working on needs to execute a job after a long delay for which currently I am using TaskAfter library. Issue here is that the server can’t keep a track of the scheduled tasks if the process dies after each deployment. Could you please help me suggest a way to schedule a delayed task without thinking about server process being killed.


you have postgres in the app? then https://hex.pm/packages/oban


One possibility is to use RabbitMQ and the delayed message exchange plugin. I use that in a project, we persist the queues on disk and run RabbitMQ in cluster mode, to obtain durability and high availability. I am very happy about the performance and reliability.

1 Like


Entirely by design, it’s purely in-process, basically a better Process.send_after is it’s purpose and use. ^.^

As the author of TaskAfter I also recommend Oban as @outlog suggested. :slight_smile:

Optionally you can serialize the state of each pending call in TaskAfter to a store somewhere and remove it when elapsed, but you can get all kinds of race conditions, that’s why things like Oban are better overall as they add the needed synchronization.