akka.netakka.net-persistence

Akka.net: assuring a timeout message is always launched


Imagine you have an actor that has a "business" timeout on it. I would like that timeout to be launched even if the server where the actor lives dies or reboot. I would create that actor as persistent.

Which is the best way to assure that a timeout will be launched even if a single server fails?

Thanks


Solution

  • I'd set it up like this:

    BA => (rqTimeoutMsg) => GDA => TM (waits) => BA => (confirmation) => TM => GDA
    

    BA = your business actor

    GDA = a guaranteed delivery actor (Akka.Persistence)

    TM = timeoutManager

    BA sends a 'timeout' request to the 'GDA' which forwards it to the Timeout manager. It waits until time X (using Scheduler, I'd suggest) then sends the 'timeout' to BA, which should confirm it back to TM or directly to GDA.

    The GDA and TM together form a persistent TimeoutManager, so they could/should be wrapped together in one Actor, which is the one the BA talks to (requestTimeout, and upon receiving 'timeout', confirmReceptionOfTimeout).

    Question however: how do you plan to make sure the BA is there after a (crash+)restart?