In the code below, remoteListeners is a list of actor string path in remote 
Actor Systems. 

I use actorFor to get the ActorRef. 


val listenersActorRefs = remoteListeners.map(path => 
context.actorFor(path)).toList 

val router = context.actorOf(Props.empty.withRouter(BroadcastRouter(routees 
= listenersActorRefs)), "remoteListeners")


Suppose the remote actors are not running when the above code is executed, 
and later, the remote actors are alive, then 

the router will automatically connect to the remote actors.


As actorFor is deprecated, I try replacing actorFor with actorSelection and 
use the following to get ActorRef


def getActorRef(path:String, context:ActorContext):ActorRef={

implicit val timeout = Timeout(3, TimeUnit.SECONDS);

val future = context.actorSelection(path).resolveOne().mapTo[ActorRef]


 val futureTimeout = Duration(3, TimeUnit.SECONDS);

val actorRef = Await.result(future, futureTimeout)

 actorRef

}

 
 The above works if all the remote actors are alive at the beginning. If 
remote actors are not alive at the beginning, I do not get the automatic 
connect

behaviour when the remote actors are alive.

 Is there a way to use actorSelection with the "lazy connect" behaviour ?

  Thanks in advance for your assistance !


Shing 

  

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      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/groups/opt_out.

Reply via email to