Hi, I want to create an actor if it didn't created already. To check its existence I use actorSelection. If there is no actor defined by the path, I create a new one with actorOf. Is this approach correct? How can I improve the design? Here is the code I come up with currently;
val fullPath: String = path.format(appId) var starter: ActorRef = null implicit val timeout = Timeout(5 seconds) try { starter = Await.result(context.actorSelection(fullPath).resolveOne,FiniteDuration(5,TimeUnit.SECONDS)) } catch { case e: ActorNotFound => { starter = context.actorOf(Props(new StarterNode(customer, appId)), name = fullPath) logger.info("Actor [" + fullPath + "] creating for first time") } case e: Exception => logger.error("Actor [" + fullPath + "] selection failed",e) } //TODO if(starter != null) { starter ! event } else { logger.warn("Starter node failed with timeout") } -- >>>>>>>>>> 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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.