2011-08-10 17 views
2

我正在尝试使用Akka TypedActors(1.1.2)。我有一个接口,如Akka TypedActor上的'Unit'方法超时,但应该是异步的

trait Namespace { 
    def cellCount: Int 
    def isEmpty: Boolean 
    def cell(key: String): Option[CellOperations[_]] 
    def cellsLike(key: String): List[CellOperations[_]] 
    def updateOrCreateCell[T](n: String, v: Option[T]=None, d:List[DataOps[T]]=List.empty[DataOps[T]]) 
} 

我有一个明确的NamespaceImpl扩展它。

class NamespaceImpl extends TypedActor with Namespace with Logging { 
    ... 
} 

而且我通过春季创建演员:

<akka:typed-actor id="namespace" 
        interface="com.fi.depends.namespace.akka.Namespace" 
        implementation="com.fi.depends.namespace.akka.NamespaceImpl" 
        timeout="10000" 
        scope="singleton"> 
</akka:typed-actor> 

在运行时我在电话会议中updateOrCreateCell,不应该不会发生这对我的理解周期性超时,因为该方法是类型单位和因此我期望它能够生成和异步调用。

在堆栈跟踪我看到:

akka.dispatch.FutureTimeoutException: Futures timed out after [10000] milliseconds 
[NYCWD2328_1c52ee80-c372-11e0-8343-0023ae9118d8] 
    at akka.dispatch.DefaultCompletableFuture.await(Future.scala:718) 
    at akka.actor.ScalaActorRef$class.$bang$bang(ActorRef.scala:1332) 
    at akka.actor.LocalActorRef.$bang$bang(ActorRef.scala:587) 
    at akka.actor.ActorAspect.localDispatch(TypedActor.scala:966) 
    at akka.actor.TypedActorAspect.dispatch(TypedActor.scala:904) 
    at akka.actor.TypedActorAspect.invoke(TypedActor.scala:899) 
    at com.fi.depends.namespace.akka.Namespace$$ProxiedByAWDelegation$$1314085842186_1__786390915__878797045___AW_JoinPoint.proceed(Unknown Source) 
    at com.fi.depends.namespace.akka.Namespace$$ProxiedByAWDelegation$$1314085842186_1__786390915__878797045___AW_JoinPoint.invoke(Unknown Source) 
    at com.fi.depends.namespace.akka.Namespace$$ProxiedByAWDelegation$$1314085842186.updateOrCreateCell$default$3(Unknown Source) 

,我看到“ScalaActorRef $类$嘭嘭$”告诉我的东西是非常错误的事实。

任何帮助,将不胜感激。

回答

0

如果实际指定“updateOrCreateCell”的返回类型为Unit,会发生什么?

+0

嗨维克托 - 我试过,得到了同样的异常和相同的堆栈跟踪。我试图剥离我的具体应用程序的细节,试图找到一个有这个问题的最小测试用例,但是我可能直到本周末才会完成。 (我试图将现有的Scala Actors应用程序移植到Akka,我不想放弃Typed Actor,因为它们使代码更清晰。) – Jim

+0

我尝试在1.2上使用TypedActor来重现问题-RC2,我不能。顺便说一句,你知道我们有一个品牌spankin新的TypedActor实施排队Akka 2.0?:https://github.com/jboner/akka/blob/86bd9aaa51fda375a1d04cb87019441a9ca56fed/akka-actor/src/main/scala/akka /actor/TypedActor.scala –

0

最好的线程necro,但我有一天遇到了类似的例外,并认为它可能在某个时候帮助某人。 :)

难道是你有一个覆盖receive方法在NamespaceImpl? 因为我做了(从演员到TypedActor切换),并且把事情搞乱酷似它没有你...

BTW:这是你可以重写receive,仍然做的东西在里面,如果你想:

override def receive = { 
    super.receive andThen { 
    case message => { 
     logger.debug("Received message: " + message) 
    } 
    } 
} 
相关问题