Skip to main content
2 de 2
removeu 1 caractere do conteúdo

use a funcção resolveOne do ActorSelection

java:


final ExecutionContext ec = system.dispatcher();

ActorSelection register = system.actorSelection("akka://default/user/ATOR-NAO-EXISTE");
Future future = register.resolveOne()
future.onSuccess(new OnSuccess() {
  public void onSuccess(ActorRef actor) {
    // the actor reference
  }
}, ec);

future.onFailure(new OnFailure() {
  public void onFailure(Throwable failure) {
    if (failure instanceof ActorNotFound) {
      // actor not found
    }
  }
}, ec);

scala:


val register = system.actorSelection("akka://default/user/ATOR-NAO-EXISTE");
val future  = register.resolveOne()
future.onSuccess({
    case actor: ActorRef => // the actor reference
  })

future.onFailure({
    case e: ActorNotFound => // actor not found
    case _ => // anything else
  })