Search code examples
asp.netasp.net-coreakkaakka.net

Schedule a conditional email message with Akka.Net


I need to implement the following logic - I send a message to the user, and if he doesn't reply, I send it again after 12 hours. I wonder what is the best way to do this? I was thinking about using Akka.NET - after a certain amount of time the actor would check if the user replied to my message and if not, would send it again.

Is there maybe an easier way? If not, there are some questions for Akka.NET

  • Do you know any good sources where I can see how this library should be used in ASP.NET Core? The documentation is not clear enough for me.
  • Where to keep the actors and the logic associated with them? In a separate project? Where can I create an actorSystem?

I'm new to this topic, thank you in advance for all the answers.


Solution

  • I theory you could just use standard actor system schedule a message order to resend an email after 12h, but this has natural problems with a fact, that if your process will crash, all of its in-memory state will be lost.

    In practice you could use one of two existing plugins, which give you durable schedules:

    • Akka.Persistence.Reminders which works on top of Akka.Persistence, so you can use it on top of any akka.net persistence plugin.
    • Another way is to use Akka.Quartz.Actor which offers dedicated actors on top of Quartz.NET and makes use of Quartz's persistence capabilities.