Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getForgotPasswordActorRef: ActorRef = {
- var actorRef: ActorRef = null
- val sel = system.actorSelection("akka://testActorSystem/user/ForgotPasswordActor")
- val future1 = sel.resolveOne()
- val res: Try[ActorRef] = Await.ready(future1, timeout.duration).value.get
- res match {
- case Success(actorref) =>
- log.info("actor exists" + actorref)
- actorRef = actorref
- case Failure(e) =>
- log.warn("in failure block actor does not exists", e)
- val forgotPasswordActorRef = system.actorOf(Props[ForgotPasswordActor].
- withDispatcher("akka.actor.ForgotPasswordActor-dispatcher"),
- name = "ForgotPasswordActor")
- log.info("created a new one " + forgotPasswordActorRef.path.toString())
- actorRef = forgotPasswordActorRef
- }
- log.info("returned actor ref is " + actorRef)
- actorRef
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement