Error message using Scala AKKA

Here is my code:

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)) } 

I get an error with this line:

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

Mistake:

could not find implicit value for timeout parameter: akka.util.Timeout

+7
source share
1 answer

add something like implicit val timeout = Timeout(5 seconds) . See http://doc.akka.io/docs/akka/2.0.1/scala/futures.html

By the way, you will also need to change

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

and

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

All Articles