askパターンを使用してakkaActorを使用して最も単純な非同期リクエストを作成しようとしていますが、akka.pattern.AskTimeoutException
何があっても受信し続けます。私が持っているのはこれです:
object Users extends Controller {
def newUser = {
val actor = Akka.system.actorOf(Props[UserRegistration])
ActorAction[String](actor, "hello")(Ok(_))
}
}
ここで、ActorAction
は通常のラッパーですAsync
:
object ActorAction {
def apply[A](actorRef: ActorRef, msg: AnyRef, timeout: Timeout = 5 seconds)(f: A => Result)(implicit m: Manifest[A]): Action[AnyContent] = {
Action {
AsyncResult {
ask(actorRef, msg, timeout).mapTo[A].asPromise.map(f)
}
}
}
}
そして、アクターは受信メッセージをログに記録して返すだけです。
class UserRegistration extends Actor {
val log = Logging(context.system, this)
def receive = {
case u => log.info("received " + u); u
}
}
メッセージのログは問題なく機能します。私はすべてを試しましたが、何も機能しません。どんな助けでも大歓迎です!
再生:2.9.1アッカ:2.0.2
スタックトレース:
[info] play - database [default] connected at jdbc:postgresql://localhost:5432/ss_dev
[info] play - Application started (Dev)
[info] play - Starting application default Akka system.
[INFO] [12/28/2012 22:10:42.51] [application-akka.actor.default-dispatcher-1] [akka://application/user/$a] received hello
[error] play - Waiting for a promise, but got an error: Timed out
akka.pattern.AskTimeoutException: Timed out
at akka.dispatch.DefaultPromise.result(Future.scala:875) [akka-actor.jar:2.0.2]
at akka.dispatch.Await$.result(Future.scala:74) ~[akka-actor.jar:2.0.2]
at play.api.libs.concurrent.AkkaPromise.await(Akka.scala:43) ~[play_2.9.1.jar:2.0.4]
at play.api.libs.concurrent.Promise$class.await(Promise.scala:55) ~[play_2.9.1.jar:2.0.4]
at play.api.libs.concurrent.AkkaPromise.await(Akka.scala:28) ~[play_2.9.1.jar:2.0.4]
at play.api.libs.concurrent.Promise$class.value(Promise.scala:53) ~[play_2.9.1.jar:2.0.4]
Caused by: akka.pattern.AskTimeoutException: Timed out
at akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:274) ~[akka-actor.jar:2.0.2]
at akka.actor.DefaultScheduler$$anon$6$$anon$7.run(Scheduler.scala:183) ~[akka-actor.jar:2.0.2]
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:94) [akka-actor.jar:2.0.2]
at akka.jsr166y.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1381) [akka-actor.jar:2.0.2]
at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259) [akka-actor.jar:2.0.2]
at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) [akka-actor.jar:2.0.2]
前もって感謝します!