If I create an logging actor like so
val logger: ActorRef =
actorSystem.actorOf(Props(new Logger()))
and the logger restarts due to an Exception, my logger stops writing to disk.
I had been sending messages logger ! msg
Am I correct in assuming that the ActorRef did not update when the supervisor restarted my logging actor?
ActorRef
should be properly updated by Akka to point to the new instance of an actor. The docs clearly state that:Also here:
That's one of the main advantages of using
ActorRef
s, otherwise it would be much more inconvenient to work with actors.You need to check your supervisor strategy and make sure that the actor is actually restarted. Default strategy is:
Thus if you get an
Exception
your actor will be restarted andActorRef
should be valid, but if you get other types ofThrowable
then it will be stopped andActorRef
will become invalid.