Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view akka dead letters

I've created an Actor that performs some basic operations and appears to be working correctly - however I'm seeing the following show up in my logs regularly

[INFO] [05/28/2014 14:24:00.673] [application-akka.actor.default-dispatcher-5] [akka://application/deadLetters] Message [akka.actor.Status$Failure] from Actor[akka://application/user/trigger_worker_supervisor#-2119432352] to Actor[akka://application/deadLetters] 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'.

I would like to actually view the contents of the Failure to establish what exactly is throwing a Failure, however I can't quite figure out how to view them.

Reading through the Akka documentation it mentions how to disable the dead-letter warning in the logs, but not how to actually write a handler to process them.

Is there a simple way to actually catch anything sent to dead-letters?

like image 528
James Davies Avatar asked May 28 '14 04:05

James Davies


People also ask

What are Dead Letters akka?

Class DeadLetterWhen a message is sent to an Actor that is terminated before receiving the message, it will be sent as a DeadLetter to the ActorSystem's EventStream. When this message was sent without a sender ActorRef , sender will be system.

How do I terminate Akka actor?

In Akka, you can stop Actors by invoking the stop() method of either ActorContext or ActorSystem class. ActorContext is used to stop child actor and ActorSystem is used to stop top level Actor.


Video Answer


1 Answers

As mentioned in the comment by @wingedsubmariner, you can subscribe to the DeadLetter event on the main system EventStream to be notified when deadletters happen and be able to react to that situation in a more custom manner. In order to subscribe, the code would look like this:

context.system.eventStream.subscribe(myListenerActorRef, classOf[DeadLetter])

Then, the receive for that listener actor could look something like this:

def receive = {
  case DeadLetter(msg, from, to) =>
    //Do my custom stuff here
}

The structure of the DeadLetter class is:

case class DeadLetter(message: Any, sender: ActorRef, recipient: ActorRef)
like image 178
cmbaxter Avatar answered Sep 17 '22 19:09

cmbaxter