Do you know the forward() function on ActorRef? I'm not certain whether it's right for your use case, but it's often the answer to this sort of design, since it sends a message while preserving the original sender. If ActorA doesn't actually need the response, it's probably correct. (The reason it might not work is if you need to send to B and C in parallel, and only respond when *both* are finished.)
If that's not an option, then likely yes, you should include the original sender() in the messages to B and C, and use that to coordinate the response. On Fri, Mar 31, 2017 at 4:53 AM, Jean Demonceau <[email protected]> wrote: > Hi guys, > > I have a sharding region that creates instances of ActorA > I want to "ask" (in order to get a synchronous reponse) the region to do > something > The problem is ActorA (that will receive the message) will dispatch the > work to ActorB and ActorC and will expect messages from them. > > When ActorA receives response from B and C it can sends a reponse to the > inital sender() saying that the job is completed. > > The problem is, since ActorA received messages from B and C, the initial > sender() is lost. > I cannot tell to context().parent() either because the parent of A is the > Shard. > > How can I do this properly ? Should I backup the initial > sender().path().toString() and response like so > context().system().actorSelection(initialSenderPath).tell("jobCompleted", > self()) ? > > Is it safe to do that ? In this case the initial sender path > is akka://MySystem/temp/$a > > Or should I put the initial sender ActorRef to messages sent to B and C > and expect to get it back from them in their response ? > > I know I could use ask in ActorA to send messages to B and C in order to > keep the original sender but I don't want to set timeouts everywhere. > > Any idea ? > Thanks :) > > -- > >>>>>>>>>> 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. > -- >>>>>>>>>> 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.
