Search code examples
javascalaakkaactor

Is possible a ActorRef change without I receive a DeadLetter message?


I need keep a ActorRef for a determinated time. While this I keep "watching" for this ActorRef.

Is possible, for some reason, that my ActorRef turns invalid, without I receive a "DeadLetter" ?

Sorry, if this question seens strange. I think that is impossible, but looking for a documentation this question is not clear for me.


Solution

  • I think you are right - seems that documentation is vague on this. However, consider this:

    Akka does not provide any delivery guarantees for messaging. That's the core of Akka philosophy.

    Consider the case where you are using remote death watch. Even if a remote Actor is terminated and Terminated message is sent to you over the network you might not get the message, or it might arrive delayed.

    In this case you will have a stale ActorRef but you'll be able to discover problems with it when you send a message to it if you subscribe to "Dead Letters". The same applies if you watch over an Actor locally and get some sort of JVM error - there is a chance that you won't receive Terminated message or fail to process it and it will be lost.

    To account for it you can build recovery and retries on top of Akka.

    So in short there are some rare situations where this could be possible. The correct question to ask is how does your application recover at every level of failure. Hope that helps.