Created
October 19, 2016 21:42
-
-
Save sc6l6d3v/dff7c46e7fa0bad83311833c8e9fb811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// works perfectly in amm | |
import $ivy.`com.typesafe.akka::akka-actor:2.4.11`,akka.actor._, scala.concurrent._, scala.concurrent.duration._ | |
val system = ActorSystem("hoge") | |
class PrintActor(dummy: String) extends Actor{ def receive = { case msg => println(msg) } } | |
val a = system.actorOf(Props(classOf[PrintActor],"first"),"aaa") | |
val b = system.actorOf(Props(classOf[PrintActor],"second"),"bbb") | |
Await.result(system.actorSelection("/user/aaa").resolveOne(1.second), 1.second) | |
{ | |
def findRef(path: String): Option[ActorRef] = | |
try { | |
Some(Await.result(system.actorSelection(s"/user/$path").resolveOne(1.second), 1.second)) | |
} catch { | |
case ex: Throwable => None | |
} | |
} | |
findRef("aaa") | |
findRef("bbb") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment