“单位” Akka TypedActor 上的方法超时,但应该是异步的
我正在尝试使用 Akka TypedActors (1.1.2)。我有一个接口,就像
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 {
...
}
我通过 Spring 创建 actor:
<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 的调用超时,据我了解,这种情况永远不会发生,因为该方法是 Unit 类型,因此我希望它生成异步调用。
在堆栈跟踪中,我看到:
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$class.$bang$bang' 告诉我有些事情非常错误。
任何帮助将不胜感激。
I am attempting to use Akka TypedActors (1.1.2). I have an interface like
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]])
}
I have a well defined NamespaceImpl which extends it.
class NamespaceImpl extends TypedActor with Namespace with Logging {
...
}
And I create the actor through Spring:
<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>
At runtime I periodically timeout on the call to updateOrCreateCell, which to my understanding should not ever happen, since the method is of type Unit and thus I expect it to generate and asynchronous call.
In the stacktrace I see:
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)
The fact that I see 'ScalaActorRef$class.$bang$bang' tells me that something is very wrong.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您实际上将“updateOrCreateCell”的返回类型指定为 Unit 会发生什么?
What happens if you actually specify a return type for "updateOrCreateCell" to be Unit?
Thread necro 处于最佳状态,但前几天我遇到了类似的异常,并认为它可能在某些时候对某人有所帮助。 :)
是否您在
NamespaceImpl
中重写了receive
方法?因为我这样做了(从 Actor 切换到 TypedActor),这把事情搞砸了,就像它为你做的那样......
顺便说一句:这就是你如何覆盖
receive
并仍然在其中做一些事情,如果你愿意的话:Thread necro at its best, but I ran into a similar exception the other day and thought that it might help somebody at some point. :)
Could it be that you have an overridden
receive
method inNamespaceImpl
?Cause I did (switched from Actor to TypedActor) and that messed things up exactly like it did for you...
BTW: This is how you can override
receive
and still do stuff in it if you want: