"Dead letters encountered" as soon as actors are placed into router

25,459

Solution 1

What you are seeing here is that DeathWatchNotifications are not processed, meaning that the actor (the Router) was still watching its children when it terminated. This is not automatically a sign of trouble as documented (but we should make it clearer in the case of this particular message). In this case the only way to get rid of this message is to make sure that router and routees do not terminate "at the same time".

Solution 2

I ran into the same problem with my akka project. Here is my question "Dead Letters encountered" error while running AKKA remote actors

Generally dead letter encountered occurs when there is no more worker actor to receive the message sent by master. You should make sure your worker actor is alive when your master is sending it a task or message.

Solution 3

One solution is to use the Scheduler, and instead of

context.stop(self)

use:

system.scheduler.scheduleOnce(1 second) {
  self ! PoisonPill
}
Share:
25,459

Related videos on Youtube

MCP
Author by

MCP

I'm a student, intern, and aspiring builder of great things. Sometimes I ask questions before I ask questions. I'm getting better at it. Thanks for reading.

Updated on July 10, 2022

Comments

  • MCP
    MCP almost 2 years

    Here's what I'm finding, and for the life of me I can't navigate to the reason. I'm creating "printer" actors that basically either do nothing, or print a message based on the type of message they receive.

    class Printer extends Actor {
        def receive = {
            case m: SomeMessage => println( m.text )
            case _ =>
        }
    }
    

    I'm creating several of these actors:

    val actor4 = system.actorOf(Props[Printer], "t-4")
    val actor5 = system.actorOf(Props[Printer], "t-5")
    val actor6 = system.actorOf(Props[Printer], "t-6")
    

    and throwing them into a vector:

    val routees2 = Vector[ActorRef](actor4, actor5, actor6)
    

    I'm doing the above so that I can throw them into a router (and they will be under the router's control). When I run the spec up to this point I'm not having any issues. As soon as I place them in a router and run the spec I'm having problems. Here's the router:

    val router = system.actorOf(Props[Printer].withRouter(
        BroadcastRouter(routees = routees2)), "router-to-transformers")
    

    Now when I run the spec I have all sorts of dead letters...

    [INFO] [09/23/2013 17:10:21.468] [spider-akka.actor.default-dispatcher-6] [akka://spider/user/router-to-transformers] Message [akka.dispatch.sysmsg.DeathWatchNotification] from Actor[akka://spider/user/router-to-transformers#-1845250548] to Actor[akka://spider/user/rout
    er-to-transformers#-1845250548] 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'.
    [INFO] [09/23/2013 17:10:21.468] [spider-akka.actor.default-dispatcher-6] [akka://spider/user/router-to-transformers] Message [akka.dispatch.sysmsg.DeathWatchNotification] from Actor[akka://spider/user/router-to-transformers#-1845250548] to Actor[akka://spider/user/rout
    er-to-transformers#-1845250548] was not delivered. [2] 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'.
    [INFO] [09/23/2013 17:10:21.468] [spider-akka.actor.default-dispatcher-6] [akka://spider/user/router-to-transformers] Message [akka.dispatch.sysmsg.DeathWatchNotification] from Actor[akka://spider/user/router-to-transformers#-1845250548] to Actor[akka://spider/user/rout
    er-to-transformers#-1845250548] was not delivered. [3] 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'.
    

    For the life of me I can't figure out what is going on here. I've added a link to a snippet of the test. The numbering, in the snippet, is weird because I've cut a bunch of different attempts that were commented out so as to not clutter the snippet. I'm focused on this dead-letters issue because I feel like when I added a more actors and actually started passing messages around, things weren't getting delivered... http://snipt.org/AhVf0

    It's worth calling out that these actors are local. I've read something about actorFor being depreciated and I'm wondering if that is being used and is partly what is causing my issues? There are so many moving parts here though and not a lot of stable, COMPREHENSIVE, documentation. Any help would be greatly appreciated.

  • MCP
    MCP over 10 years
    Instead of using the: val router = system.actorOf(Props(CreateDiagnostic).withRouter( BroadcastRouter(routees = routees2)), "router") syntax I switched to: val router = system.actorOf(Props(createDiagnostic).withRouter( BroadcastRouter(nrOfInstances = 3)), "router") which made the dead-letters go away. I'm assuming this second implementation is the cleaner way to do it? As always, thanks.

Related