Vinicius Carvalho
unread,May 9, 2012, 10:58:16 PM5/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to play-framework
Hi, just trying to get actors and play but not getting this error:
package actors
import akka.actor.Actor
import scala.util.Random
import akka.util.Timeout
import akka.util.duration._
class NodeBalancer extends Actor{
def receive = {
case nodeId : Int =>
val r = new Random
val wait = r.nextInt(80) + 20
Thread.sleep(wait)
sender ! ("Node id " + nodeId + " took " + wait + " ms to be
processed")
case _ => println("WTF")
}
}
object NodeBalancer {
implicit val timeout = Timeout(1 second)
}
def index = Action {
val actor = Akka.system.actorOf(Props[NodeBalancer], name ="node
balancer")
Async {
(actor ? 17).mapTo[String].asPromise.map {
response => Ok(response)
}
}
}
I get an error, as ActorRef does not contain the ? method. Really
confused here, thought that ? (ask) was the way to get a future from
an actor.
Regards