Reputation: 13
I'm building an application that requires delayed response to a sender
reference pointing to the upstream sender. For clarity, if actor A sends a message to actor B, then A is the sender
of B.
Upon A's failure and restart by its supervisor, does the sender
reference held by B still point to the newly restarted A actor?
Upvotes: 1
Views: 34
Reputation: 11307
Yes, after a restart the ActorRef
points to the new actor instance which is considered to belong to the same actor incarnation (see the actor lifecycle section of in the Akka docs).
The documentation also states this explicitly here:
Equality of
ActorRef
match the intention that anActorRef
corresponds to the target actor incarnation. Two actor references are compared equal when they have the same path and point to the same actor incarnation. A reference pointing to a terminated actor does not compare equal to a reference pointing to another (re-created) actor with the same path. Note that a restart of an actor caused by a failure still means that it is the same actor incarnation, i.e. a restart is not visible for the consumer of theActorRef
.
So it makes a differences whether the actor is terminated and another instance is created or it is restarted by the supervisor.
Upvotes: 1