简体   繁体   中英

Akka - implement a custom DeadLetterListener actor

I am trying to add additional behaviour for handling dead letters in Akka. I am thinking the best way to do this is by implementing our own dead letter listener, but I can't find any documentation on how to integrate our own actor instead of the default dead letter listener.

Is there any documentation on how to go about doing this (or is there another approach for extending or overriding the behaviour of these default implementations?

You should subscribe to EventStream for this.

import akka.actor.{ Actor, DeadLetter, Props }

class Listener extends Actor {
  def receive = {
    case d: DeadLetter => println(d)
  }
}

val listener = system.actorOf(Props(classOf[Listener]))
system.eventStream.subscribe(listener, classOf[DeadLetter])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM