0
votes

I have an Actor that I create from with another Actor (parent). I also spawn several other Actor's from within the parent. The tree looks like:

ParentActor
 -- ServiceActor
 -- ProcessActor1
 -- ProcessActor2

Now I want to pass around this ServiceActor instance to ProcessActor instances, but the problem is that the ServiceActor could choke and be killed at some point. I handle this in my parent and I would have a Restart policy for the ServiceActor.

Now my question is say if I create all my Actors as mentioned above and after a couple of hours the ServiceActor gets Restarted because of an Exception happening, should I re-instantiate my ProcessActor's?

Is the old ServiceActor ActorRef reference still valid?

1

1 Answers

2
votes

An ActorRef is valid even if the underlying actor is restarted multiple times. From the official documentation:

The rich lifecycle hooks of Actors provide a useful toolkit to implement various initialization patterns. During the lifetime of an ActorRef, an actor can potentially go through several restarts, where the old instance is replaced by a fresh one, invisibly to the outside observer who only sees the ActorRef.