Added actor termination coordinated shutdown task #27089

A convenience method that allows creating a
shutdown task by sending a message to an actor, and watching for its
termination.
This commit is contained in:
James Roper 2019-07-16 18:56:48 +10:00 committed by Johan Andrén
parent d3170a56ea
commit 511356177d
5 changed files with 195 additions and 2 deletions

View file

@ -875,4 +875,18 @@ public class ActorDocTest extends AbstractJavaTest {
// #coordinated-shutdown-run
}
}
@Test
public void coordinatedShutdownActorTermination() {
ActorRef someActor = system.actorOf(Props.create(FirstActor.class));
someActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
// #coordinated-shutdown-addActorTerminationTask
CoordinatedShutdown.get(system)
.addActorTerminationTask(
CoordinatedShutdown.PhaseBeforeServiceUnbind(),
"someTaskName",
someActor,
Optional.of("stop"));
// #coordinated-shutdown-addActorTerminationTask
}
}