Package org.apache.pekko.actor.typed
Class SpawnProtocol
java.lang.Object
org.apache.pekko.actor.typed.SpawnProtocol
A message protocol for actors that support spawning a child actor when receiving a
SpawnProtocol#Spawn
message and sending back the ActorRef
of the child actor. Create instances through the apply()
or create()
factory methods.
The typical usage of this is to use it as the guardian actor of the ActorSystem
, possibly combined with
Behaviors.setup
to starts some initial tasks or actors. Child actors can then be started from the outside
by telling or asking SpawnProtocol#Spawn
to the actor reference of the system. When using ask
this is
similar to how pekko.actor.ActorSystem#actorOf
can be used in classic actors with the difference that
a Future
/ CompletionStage
of the ActorRef
is returned.
Stopping children is done through specific support in the protocol of the children, or stopping the entire spawn protocol actor.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Not for user extensionstatic final class
Spawn a child actor with the givenbehavior
and send back theActorRef
of that child to the givenreplyTo
destination.static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Behavior<SpawnProtocol.Command>
apply()
Scala API: returns a behavior that can be commanded to spawn arbitrary children.static Behavior<SpawnProtocol.Command>
create()
Java API: returns a behavior that can be commanded to spawn arbitrary children.
-
Constructor Details
-
SpawnProtocol
public SpawnProtocol()
-
-
Method Details
-
create
Java API: returns a behavior that can be commanded to spawn arbitrary children. -
apply
Scala API: returns a behavior that can be commanded to spawn arbitrary children.
-