Package akka.pattern
Interface GracefulStopSupport
-
public interface GracefulStopSupport
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description scala.concurrent.Future<java.lang.Object>
gracefulStop(ActorRef target, scala.concurrent.duration.FiniteDuration timeout, java.lang.Object stopMessage)
Returns aFuture
that will be completed with success (valuetrue
) when existing messages of the target actor has been processed and the actor has been terminated.java.lang.Object
gracefulStop$default$3()
-
-
-
Method Detail
-
gracefulStop
scala.concurrent.Future<java.lang.Object> gracefulStop(ActorRef target, scala.concurrent.duration.FiniteDuration timeout, java.lang.Object stopMessage)
Returns aFuture
that will be completed with success (valuetrue
) when existing messages of the target actor has been processed and the actor has been terminated.Useful when you need to wait for termination or compose ordered termination of several actors, which should only be done outside of the ActorSystem as blocking inside Actors is discouraged.
IMPORTANT NOTICE: the actor being terminated and its supervisor being informed of the availability of the deceased actor’s name are two distinct operations, which do not obey any reliable ordering. Especially the following will NOT work:
def receive = { case msg => Await.result(gracefulStop(someChild, timeout), timeout) context.actorOf(Props(...), "someChild") // assuming that that was someChild’s name, this will NOT work }
If the target actor isn't terminated within the timeout the
Future
is completed with failureAskTimeoutException
.If you want to invoke specialized stopping logic on your target actor instead of PoisonPill, you can pass your stop command as a parameter:
gracefulStop(someChild, timeout, MyStopGracefullyMessage).onComplete { // Do something after someChild being stopped }
-
gracefulStop$default$3
java.lang.Object gracefulStop$default$3()
-
-