2012-07-13 15 views
7

Ecco il mio codice:Messaggio di errore con Scala AKKA Attore

class testActor extends Actor { 
    var test = "test2" 
    def receive = { 
      case "test" ⇒ 
        "works" 
    } 
} 

def test = Action { 
    var test = "test" 
    val system = ActorSystem("MySystem") 
    val myActor = system.actorOf(Props[testActor.testActor], name = "testActor") 

    test = Await.result(myActor ? "test", Duration(1, TimeUnit.SECONDS)) 
} 

sto ottenendo un errore con questa linea:

test = Await.result(myActor ? "test", Duration(1, TimeUnit.SECONDS)) 

L'errore è:

non riusciva a trovare valore implicito per il timeout del parametro: akka.util.Timeout

risposta

13

aggiungere qualcosa come implicit val timeout = Timeout(5 seconds). Vedere http://doc.akka.io/docs/akka/2.0.1/scala/futures.html

Tra l'altro, avrete anche bisogno di cambiare

def receive = { 
     case "test" ⇒ sender ! "works" 
} 

e

test = Await.result(myActor ? "test", timeout.duration).asInstanceOf[String] 
+0

Cosa succede se voglio utilizzare semplicemente il default. http://doc.akka.io/api/akka/2.0/akka/actor/ActorRef.html menziona (nei commenti) che c'è un 'akka.actor.timeout'. Come farlo kick? – akauppi

Problemi correlati