I have read this doc https://doc.akka.io/docs/akka/current/general/message-delivery-reliability.html#dead-letters, which says:
An actor can subscribe to class akka.actor.DeadLetter on the event stream, see Event Stream for how to do that.
in the Event Stream doc: https://doc.akka.io/docs/akka/current/event-bus.html#event-stream, sample code seems about classic Akka, and package is akka.actor.ActorSystem
not akka.actor.typed.ActorSystem
:
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
final ActorSystem system = ActorSystem.create("DeadLetters");
final ActorRef actor = system.actorOf(Props.create(DeadLetterActor.class));
system.getEventStream().subscribe(actor, DeadLetter.class);
but in Akka Typed, there is no method named subscribe()
inakka.actor.typed.ActorSystem.eventStream()
.
After creating a typed ActorSystem and a typed Actor that handles the message type DeadLetter, you should be able to subscribe to the EventStream like shown below.
import akka.actor.typed.eventstream.EventStream;
system.eventStream().tell(new EventStream.Subscribe(DeadLetter.class, actor));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With