I’m using Akka-Typed 2.5 and have an intermittent race condition of sending a message to an actor that has shut down before I received the
Terminated message. Since this is an edge case, I figured the simplest way is to listen to
DeadLetters and handle the re-create/re-send from there. Since 2.5 doesn’t seem to have a typed event stream, I tried subscripting the classic way via:
val untyped = context.system.toClassic val listener = untyped.actorOf(Props[DeadLetterListener]) untyped.eventStream.subscribe(listener, classOf[DeadLetter])
However, that dies at
java.lang.UnsupportedOperationException: cannot create top-level actor from the outside on ActorSystem with custom user guardian.
Is there a different way to subscribe to deadletters in akka-typed 2.5?
I can’t easily upgrade to 2.6 because of a number of breaking changes, the main blocker being that
behavior orElse Behaviors.receiveMessagePartial[T] no longer exists which I use extensively as a behavior wrapper for localized logging of
Unhandled messages in state machines.