Michael, thank you so much! this answers all my questions.

Fantastic and clean how these are done under the hood. I will make sure to 
stick closely to the mediating temp holding the future then resolving it. 

Kudos,
Mo

On Friday, March 25, 2016 at 3:09:51 PM UTC-6, Michael Frank wrote:
>
> On 03/24/16 12:25, Mohammed Al-Mahfoudh wrote:
>
> - If an ask statement, that sends a message *m1* from *a1* to *a2* 
> (actors), must *a2* reply right away in the same "receive" invocation? or 
> we can have another *receive* invocation reply to that ask? (I mean by 
> reply also resolving the future)
>
> no, a2 does not need to reply immediately in the same receive invocation.  
> yes, another iteration of the receive loop can reply.  another actor even 
> can reply to the future.
>
> - How can that be implemented (abstractly speaking) since *a2* doesn't 
> have an explicit handle for the Future object returned by the above ask?
>
> when you call ask(), what happens under the covers is a temporary actor is 
> created as a mediator between a1 and a2.  this temporary actor (call it 
> temp1) holds the future.  when the message is sent from a1 to a2, ask() 
> actually sends the message to temp1, which then resends the message.  this 
> is important, because it changes the sender address to that of temp1, not 
> a1.  when a2 receives the message, sender() == temp1.  when a2 replies, 
> temp1 receives the message and completes the future.
>
>     - Is there a "mapping" between which message sent back to *a1* 
> resolves which Future it asked for? If so, how to map that? (do you 
> encapsulate the original message *m1* inside the later message sent from 
> a1 to a2 for replying, and then the ActorSystem knows how to resolve that 
> Future in the destination actor?)
>
>
> no, there is no mapping.  you have to do so yourself (if that is important 
> to you) by mapping the future returned  from ask().
>
> -Michael
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to