'Unit' method on Akka TypedActor times out, but should be asynchronous

324 Views Asked by At

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.

2

There are 2 best solutions below

2
Viktor Klang On

What happens if you actually specify a return type for "updateOrCreateCell" to be Unit?

0
LeChe On

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 in NamespaceImpl? 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:

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