Nothing can ensure that the other actor receives the message, but with actor refs you can use death watch (also remote death watch), i.e. you are notified if the other actor dies. You can’t watch actor selections.
Heiko On 28 May 2014, at 17:42, Ketil Johannessen <[email protected]> wrote: > > But can you please explain why using an actorref ensures no dead letter, > while an actorSelection > may cause this. Example pseudocode as follows: > > Using actorref: > val ref = context.actorOf(Props(classOf[ChildActor],ChildActor.NAME) > ref ! "test" // <--- this is okay > > while using actorSelection results sometimes in DeadLetter due to delayed > child actor instantiation: > val ref = context.actorOf(Props(classOf[ChildActor],ChildActor.NAME) > > val selection = context.actorSelection(something) > selection ! "test" // <-- results in DeadLetter sporadically > > > On Wednesday, May 28, 2014 5:28:43 PM UTC+2, Heiko Seeberger wrote: > Actor selection essentially is look up and we all know that look up should > not be overused. It has it’s purpose though, e.g. when you want to connect to > a remote system (How would you get an actor ref for a remote actor?). Rule of > thumb: If you have an actor ref, use it. > > Heiko > > On 28 May 2014, at 16:31, Filippo De Luca <[email protected]> wrote: > >> Hi Heiko, >> So moving forward, is the actor selection a bad practice instead? The >> temptation to don't pass the actorRef and instead let the actor search for >> the dependencies is high, but I see difficulties to test and and heavy >> dependency on the actor system hierarchy. >> >> Any thoughts on that? Thanks. >> >> On 28 May 2014 14:41, Heiko Seeberger <[email protected]> wrote: >> Then your problem is not related to the ask pattern, but using >> `ActorSelection` instead of `ActorRef`. >> >> >> >> >> -- >> Filippo De Luca >> --------------------- >> WWW: http://filippodeluca.com >> IM: [email protected] >> >> -- >> >>>>>>>>>> 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 http://groups.google.com/group/akka-user. >> For more options, visit https://groups.google.com/d/optout. > > > -- > > Heiko Seeberger > Twitter: @hseeberger > Blog: blog.heikoseeberger.name > > > > > > -- > >>>>>>>>>> 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 http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. -- Heiko Seeberger Twitter: @hseeberger Blog: blog.heikoseeberger.name -- >>>>>>>>>> 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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
