Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. def getForgotPasswordActorRef: ActorRef = {
  2. var actorRef: ActorRef = null
  3. val sel = system.actorSelection("akka://testActorSystem/user/ForgotPasswordActor")
  4. val future1 = sel.resolveOne()
  5. val res: Try[ActorRef] = Await.ready(future1, timeout.duration).value.get
  6. res match {
  7. case Success(actorref) =>
  8. log.info("actor exists" + actorref)
  9. actorRef = actorref
  10.  
  11. case Failure(e) =>
  12. log.warn("in failure block actor does not exists", e)
  13. val forgotPasswordActorRef = system.actorOf(Props[ForgotPasswordActor].
  14. withDispatcher("akka.actor.ForgotPasswordActor-dispatcher"),
  15. name = "ForgotPasswordActor")
  16. log.info("created a new one " + forgotPasswordActorRef.path.toString())
  17. actorRef = forgotPasswordActorRef
  18. }
  19. log.info("returned actor ref is " + actorRef)
  20. actorRef
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement