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 am getting an error with this line:
test = Await.result(myActor ? "test", Duration(1, TimeUnit.SECONDS))
The error is:
could not find implicit value for parameter timeout: akka.util.Timeout
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'll also need to change
def receive = {
case "test" ⇒ sender ! "works"
}
and
test = Await.result(myActor ? "test", timeout.duration).asInstanceOf[String]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With