Question

I have a very simple structure based on Akka actors in Scala, but I keep on receiving warnings about undelivered messages. This is the code for the main class, Collector is a separate class extending Actor:

object Executor extends App {

  class ExecutorMaster extends Actor {

    def receive() = {
      case _ => Executor.actorSystem.actorOf(Props[Collector], name = "Collector") ! true
    }

  }

  val actorSystem = ActorSystem("ReadScheduler")
  private val app = actorSystem.actorOf(Props[ExecutorMaster], name = "Executor")

  app ! true

}

The message is not being delivered to the Collector, the result for the code is:

[04/27/2014 18:09:05.518] [ReadScheduler-akka.actor.default-dispatcher-3] [akka://ReadScheduler/user/Collector] Message [java.lang.Boolean] from Actor[akka://ReadScheduler/user/Executor#2127791644] to Actor[akka://ReadScheduler/user/Collector#337715308] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.

What can be the reason of this unsuccessful delivery of the message? Is there something that I keep on missing in the concept?

Was it helpful?

Solution

You should use a hierarchy - launch that Collector as a child of the ExecutorMaster.

What you are doing inside the receive method is attempting to create an actor having the same name as another one that gets created after the first message that the ExecutorMaster receives.

Consider using:

val collector = context.actorOf(Props[Collector], name = "Collector")
def receive = {
    case _ => collector ! true
}

You also ought to use a case object and not a primitive to identify the meaning of true.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top