0

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

Pablo Castilla
  • 2,723
  • 2
  • 28
  • 33

1 Answers1

1

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?

Bart de Boer
  • 381
  • 2
  • 7
  • About the question my first idea is to recreate certain actors with a "wake up" message. I don't know if this is a best practice. I would love to here more ideas. – Pablo Castilla Jun 01 '16 at 17:52
  • I suppose I could always recreate that TimeoutManager the way I said in my previous comment. – Pablo Castilla Jun 01 '16 at 17:53
  • TimeoutManager in this idea would be a singleton (per node, or even shared in a cluster) so created on startup. Question is however what about the recreation of the **business actor**? – Bart de Boer Jun 01 '16 at 18:28
  • The business actor would be recreated when the time out message, or another business one, is sent to the business actor. It would be also a singleton. It should work, shouldn't it? – Pablo Castilla Jun 01 '16 at 20:53