I have to create a set of persistent actors and route messages to them by some id. When I do this, in my router actor I look up the target one using something like:
context.child(id) getOrElse create(id) - creating actors by context.actorOf()
and after the router has found the child, it forwards the message (otherwise creates the child first).
To save the space, I'm also using some sort of custom passivation for the child actors by calling on them - setReceiveTimeout
=> ReceiveTimeout
=> send the actor to be passivated a custom Shutdown message, on receiving which it calls context.stop(self)
.
What if the actual actor shutdown occurs just after the parent actor has obtained the ActorRef
to the child which is already in progress of stopping, but before it forwards the message? Would the message be lost?
I thought this problem is handled in akka sharding (by ShardRegion, probably) by saving the incoming messages and replaying them on actor reactivation.
The problem is due to requirements I cannot use Akka Sharding. Is there a ready solution or a pattern to the problem of handling messages for passivating actors?
Thanks