Each Actor has a path. From inside Actor you can say:
context.path
From outside a Actor , if you have an ActorRef , you can simply say:
ref.path
This way, if the address of this instance is a separate actor, and I believe that the internal routing system routes messages to mailboxes for instances of subjects. When you are outside of Actor , for example, when you execute a loop and send messages in your example, when you use ask ( ? ), A temporary instance of Actor launched, so when the Actor to which the message is received needs to be answered, it has a path for response. This probably makes things a little easier, and it may not be the level of detail you are looking for, so I apologize if I missed the point of your question.
Also, sender var in Actor is an ActorRef , so it has a path so you can get back to it.
When Future is created, akka creates a temporary (and addressable) Actor that basically serves this Future . When this temporary Actor sends another Actor , its ActorRef is passed as the sender. When the receiving actor processes this particular message, the sender var set to ActorRef for this temporary actor, that is, you have an address to respond to. Even if you decide to hold this sender at a later date, you still have an address to send back and, ultimately, complete Future , which is served by a temporary actor. The thing is, as long as you have an ActorRef , whether it is a request or a response, all that it does is direct the message to the path for that ActorRef .
Ask (?) And tell (!) Ask (?) really not very different from each other. ask is basically tell , where the sender expects the recipient to return a tell message to him.
source share