Reputation: 4179
I have a test on an "Akka Classic" actor the is testing the persistence.
The logic is simple:
I'm migrating it to AKKA 2.6 and "AKKA Typed", but a Kill and PoisonKill are not available.
From the documentation:
PoisonPill is not supported in Typed. Instead, if you need to request an actor to stop you should define a message that the actor understands and let it return Behaviors.stopped when receiving that message.
But the PoisonPill behavior is easy to reproduce with the TestKit.stop utility.
But how about Kill? It throws an ActorKilledException that will be managed for the supervisor. How to do it in Akka Typed?
So the question is: How to implement this test using "AKKA Typed"?
Upvotes: 0
Views: 588
Reputation: 175
in care of stopping actors, the ActorRef
can use toClassic
when akka.actor.typed.scaladsl.adapter._
was imported and send the Signal akka.actor.typed.internal.PoisonPill
.
When define receiveSignal
and logging all signals, the pill does the expected work and your actor is stopped.
.receiveSignal {
case (ctx, signal) =>
ctx.log.debug("{}", signal)
Behaviors.stopped
}
first PoisonPill
then PostStop
was logged in my case.
Upvotes: 1