Class ActorSystem<T>
- All Implemented Interfaces:
Serializable,Comparable<ActorRef<?>>,ClassicActorSystemProvider,ActorRef<T>,Extensions,RecipientRef<T>
apply(org.apache.pekko.actor.typed.Behavior<T>, java.lang.String) from a Behavior object that describes the root
Actor of this hierarchy and which will create all other Actors beneath it.
A system also implements the ActorRef type, and sending a message to
the system directs that message to the root Actor.
Not for user extension.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.pekko.actor.typed.ActorRef
ActorRef.ActorRefOps<T>, ActorRef.ActorRefOps$Nested classes/interfaces inherited from interface org.apache.pekko.actor.typed.RecipientRef
RecipientRef.RecipientRefOps<T>, RecipientRef.RecipientRefOps$ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Addressaddress()Obtains the external address of the default transport.static <T> ActorSystem<T>Scala API: Create an ActorSystemstatic <T> ActorSystem<T>Scala API: Create an ActorSystemstatic <T> ActorSystem<T>apply(Behavior<T> guardianBehavior, String name, com.typesafe.config.Config config, Props guardianProps) Scala API: Create an ActorSystemstatic <T> ActorSystem<T>apply(Behavior<T> guardianBehavior, String name, BootstrapSetup bootstrapSetup) Scala API: Shortcut for creating an actor system with custom bootstrap settings.static <T> ActorSystem<T>apply(Behavior<T> guardianBehavior, String name, ActorSystemSetup setup, Props guardianProps) Scala API: Creates a new actor system with the specified name and settings The core actor system settings are defined inBootstrapSetupstatic <T> Propsstatic <T> ActorSystem<T>Java API: Create an ActorSystemstatic <T> ActorSystem<T>Java API: Create an ActorSystemstatic <T> ActorSystem<T>create(Behavior<T> guardianBehavior, String name, com.typesafe.config.Config config, Props guardianProps) Java API: Create an ActorSystemstatic <T> ActorSystem<T>create(Behavior<T> guardianBehavior, String name, BootstrapSetup bootstrapSetup) Java API: Shortcut for creating an actor system with custom bootstrap settings.static <T> ActorSystem<T>create(Behavior<T> guardianBehavior, String name, ActorSystemSetup setups) Java API: Creates a new actor system with the specified name and settings The core actor system settings are defined inBootstrapSetupabstract <U> ActorRef<U>The deadLetter address is a destination that will accept (and discard) every message sent to it.abstract DispatchersFacilities for lookup up thread-pools from configuration.abstract DynamicAccessClassLoader wrapper which is used for reflective accesses internally.Main event bus of this actor system, used for example for logging.abstract scala.concurrent.ExecutionContextExecutorThe default thread pool of this ActorSystem, configured with settings inpekko.actor.default-dispatcher.abstract CompletionStage<Done>Java API: Returns a CompletionStage which will be completed after the ActorSystem has been terminated and termination hooks have been executed.abstract <U> ActorRef<U>An ActorRef that ignores any incoming messages.abstract org.slf4j.Loggerlog()ALoggerthat can be used to emit log messages without specifying a more detailed source.abstract voidLog the configuration.abstract Stringname()The name of this actor system, used to distinguish multiple ones within the same JVM & class loader.abstract StringCreate a string representation of the actor hierarchy within this system for debugging purposes.Return a reference to this system’spekko.actor.typed.receptionist.Receptionist.abstract SchedulerA generic scheduler that can initiate the execution of tasks after some delay.abstract Settingssettings()The core settings extracted from the supplied configuration.abstract longStart-up time in milliseconds since the epoch.abstract <U> ActorRef<U>systemActorOf(Behavior<U> behavior, String name, Props props) Create an actor in the "/system" namespace.<U> Propsabstract voidTerminates this actor system by runningpekko.actor.CoordinatedShutdownwith reasonpekko.actor.CoordinatedShutdown.ActorSystemTerminateReason.abstract ThreadFactoryA ThreadFactory that can be used if the transport needs to create any Threadsabstract longuptime()Up-time of this actor system in seconds.abstract scala.concurrent.Future<Done>Scala API: Returns a Future which will be completed after the ActorSystem has been terminated.static ActorSystem<scala.runtime.Nothing$>wrap(ActorSystem system) Wrap a classicpekko.actor.ActorSystemsuch that it can be used from Pekko TypedBehavior.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.actor.typed.ActorRef
narrow, path, tell, unsafeUpcast, writeReplaceMethods inherited from interface org.apache.pekko.actor.ClassicActorSystemProvider
classicSystemMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.apache.pekko.actor.typed.Extensions
extension, hasExtension, registerExtension
-
Constructor Details
-
ActorSystem
public ActorSystem()
-
-
Method Details
-
apply
Scala API: Create an ActorSystem -
apply
public static <T> ActorSystem<T> apply(Behavior<T> guardianBehavior, String name, com.typesafe.config.Config config) Scala API: Create an ActorSystem -
apply
public static <T> ActorSystem<T> apply(Behavior<T> guardianBehavior, String name, com.typesafe.config.Config config, Props guardianProps) Scala API: Create an ActorSystem -
apply
public static <T> ActorSystem<T> apply(Behavior<T> guardianBehavior, String name, ActorSystemSetup setup, Props guardianProps) Scala API: Creates a new actor system with the specified name and settings The core actor system settings are defined inBootstrapSetup -
apply
public static <T> ActorSystem<T> apply(Behavior<T> guardianBehavior, String name, BootstrapSetup bootstrapSetup) Scala API: Shortcut for creating an actor system with custom bootstrap settings. Same behavior as callingActorSystem(name, ActorSystemSetup(bootstrapSetup)) -
apply$default$4
-
create
Java API: Create an ActorSystem -
create
public static <T> ActorSystem<T> create(Behavior<T> guardianBehavior, String name, com.typesafe.config.Config config) Java API: Create an ActorSystem -
create
public static <T> ActorSystem<T> create(Behavior<T> guardianBehavior, String name, com.typesafe.config.Config config, Props guardianProps) Java API: Create an ActorSystem -
create
public static <T> ActorSystem<T> create(Behavior<T> guardianBehavior, String name, ActorSystemSetup setups) Java API: Creates a new actor system with the specified name and settings The core actor system settings are defined inBootstrapSetup -
create
public static <T> ActorSystem<T> create(Behavior<T> guardianBehavior, String name, BootstrapSetup bootstrapSetup) Java API: Shortcut for creating an actor system with custom bootstrap settings. Same behavior as callingActorSystem.create(name, ActorSystemSetup.create(bootstrapSettings)) -
wrap
Wrap a classicpekko.actor.ActorSystemsuch that it can be used from Pekko TypedBehavior. -
name
The name of this actor system, used to distinguish multiple ones within the same JVM & class loader. -
settings
The core settings extracted from the supplied configuration. -
logConfiguration
public abstract void logConfiguration()Log the configuration. -
log
public abstract org.slf4j.Logger log()ALoggerthat can be used to emit log messages without specifying a more detailed source. Typically it is desirable to use the dedicatedLoggeravailable from each Actor’sTypedActorContextas that ties the log entries to the actor. -
startTime
public abstract long startTime()Start-up time in milliseconds since the epoch. -
uptime
public abstract long uptime()Up-time of this actor system in seconds. -
threadFactory
A ThreadFactory that can be used if the transport needs to create any Threads -
dynamicAccess
ClassLoader wrapper which is used for reflective accesses internally. This is set to use the context class loader, if one is set, or the class loader which loaded the ActorSystem implementation. The context class loader is also set on all threads created by the ActorSystem, if one was set during creation. -
scheduler
A generic scheduler that can initiate the execution of tasks after some delay. It is recommended to use the ActorContext’s scheduling capabilities for sending messages to actors instead of registering a Runnable for execution using this facility. -
dispatchers
Facilities for lookup up thread-pools from configuration. -
executionContext
public abstract scala.concurrent.ExecutionContextExecutor executionContext()The default thread pool of this ActorSystem, configured with settings inpekko.actor.default-dispatcher. -
terminate
public abstract void terminate()Terminates this actor system by runningpekko.actor.CoordinatedShutdownwith reasonpekko.actor.CoordinatedShutdown.ActorSystemTerminateReason.If
pekko.coordinated-shutdown.run-by-actor-system-terminateis configured tooffit will not runCoordinatedShutdown, but theActorSystemand its actors will still be terminated.This will stop the guardian actor, which in turn will recursively stop all its child actors, and finally the system guardian (below which the logging actors reside).
This is an asynchronous operation and completion of the termination can be observed with
ActorSystem.whenTerminatedorActorSystem.getWhenTerminated. -
whenTerminated
Scala API: Returns a Future which will be completed after the ActorSystem has been terminated. TheActorSystemcan be stopped withActorSystem.terminateor by stopping the guardian actor.Be careful to not schedule any operations, such as
onComplete, on the dispatchers (ExecutionContext) of this actor system as they will have been shut down before this future completes. -
getWhenTerminated
Java API: Returns a CompletionStage which will be completed after the ActorSystem has been terminated and termination hooks have been executed. TheActorSystemcan be stopped withActorSystem.terminateor by stopping the guardian actor.Be careful to not schedule any operations, such as
thenRunAsync, on the dispatchers (Executor) of this actor system as they will have been shut down before this CompletionStage completes. -
deadLetters
The deadLetter address is a destination that will accept (and discard) every message sent to it. -
ignoreRef
An ActorRef that ignores any incoming messages. -
printTree
Create a string representation of the actor hierarchy within this system for debugging purposes.The format of the string is subject to change, i.e. no stable “API”.
-
systemActorOf
Create an actor in the "/system" namespace. This actor will be shut down during system.terminate only after all user actors have terminated.This is only intended to be used by libraries (and Pekko itself). Applications should use ordinary
spawn. -
systemActorOf$default$3
-
receptionist
Return a reference to this system’spekko.actor.typed.receptionist.Receptionist. -
eventStream
Main event bus of this actor system, used for example for logging. Acceptspekko.actor.typed.eventstream.EventStream.Command. -
address
Obtains the external address of the default transport.Consider differences in clustered and non-clustered ActorSystems. For a non-clustered ActorSystem, this will return an address without host and port. For a clustered ActorSystem, this will return the address that other nodes can use to communicate with this node.
-