Don't use ask() -- you're blocking for no reason. Just tell() the other two 
actors, and finish what you can with the information you have. Then, when 
the responses from those two actors come in, do what you can with that 

Jonas and Viktor wrote an article for O'Reilly where they said this:

Reactive programming... is a subset of asynchronous programming and a 
> paradigm where *the availability of new information drives the logic 
> forward rather than having control flow driven by a thread-of-execution*.

Emphasis is mine. Rather than depending on ask() to try to force everything 
into a single thread, accept that the information will come in sometime 
after you ask for it -- maybe not in the order you asked for it -- and 
finish the task after the answers come in.

On Friday, February 9, 2018 at 2:21:52 AM UTC-5, Tanmoy Bandyopadhyay wrote:
> Hello,
> I am new to Akka. I am a bit confused with parallel Akka calls from an 
> Akka actor. What I was trying to do is to make parallel-concurrent calls to 
> two other actors using ask and awaiting for future to get resolved.
> public class Actor1 extends UntypedActor {
> public void onReceive(Object message) throws Throwable {
> Future<Object> searchFuture1 = ask(actor2, requestMessage, 
> ResponseMessage responseMessage1 = (ResponseMessage) 
> Await.result(searchFuture1, Duration.create(FUTURE_ACTOR_TIMEOUT, 
> Future<Object> searchFuture2 = ask(actor3, requestMessage, 
> ResponseMessage responseMessage2 = (ResponseMessage) 
> Await.result(searchFuture2, Duration.create(FUTURE_ACTOR_TIMEOUT, 
> //logic to merge both the response messages
> }
> }
> It looks sequential while making the calls to the separate actors. I want 
> the calls(ask) to the actors in parallel. How can I achieve it.?Please help 
> me to understand.
> Thanks in Advance.
> Tanmoy

>>>>>>>>>>      Read the docs:
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>>      Search the archives:
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 post to this group, send email to
Visit this group at
For more options, visit

Reply via email to