Hi,

using Await.result will block until the future is resolved. This is why
your calls are sequential. For your purpose, you might want to look into
combining ask with pipe: https://doc.akka.io/docs/akka/2.5/futures.html#
use-with-actors

That is, rather than using ask and pipe between actors, it may make sense
(on a local system) to combine responses from multiple actors together
using e.g. correlation IDs and switching behaviour in between.

Manuel

On 9 February 2018 at 08:21, Tanmoy Bandyopadhyay <tanban1...@gmail.com>
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,
> FUTURE_ACTOR_TIMEOUT);
> ResponseMessage responseMessage1 = (ResponseMessage)
> Await.result(searchFuture1, Duration.create(FUTURE_ACTOR_TIMEOUT,
> TimeUnit.MILLISECONDS));
>
> Future<Object> searchFuture2 = ask(actor3, requestMessage,
> FUTURE_ACTOR_TIMEOUT);
> ResponseMessage responseMessage2 = (ResponseMessage)
> Await.result(searchFuture2, Duration.create(FUTURE_ACTOR_TIMEOUT,
> TimeUnit.MILLISECONDS));
>
> //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: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/c
> urrent/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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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