abstract class ActorSystem extends ActorRefFactory with ClassicActorSystemProvider
An actor system is a hierarchical group of actors which share common configuration, e.g. dispatchers, deployments, remote capabilities and addresses. It is also the entry point for creating or looking up actors.
There are several possibilities for creating actors (see pekko.actor.Props
for details on props
):
// Java or Scala system.actorOf(props, "name") system.actorOf(props) // Scala system.actorOf(Props[MyActor], "name") system.actorOf(Props(classOf[MyActor], arg1, arg2), "name") // Java system.actorOf(Props.create(MyActor.class), "name"); system.actorOf(Props.create(MyActor.class, arg1, arg2), "name");
Where no name is given explicitly, one will be automatically generated.
Important Notice:
This class is not meant to be extended by user code. If you want to actually roll your own Akka, it will probably be better to look into extending pekko.actor.ExtendedActorSystem instead, but beware that you are completely on your own in that case!
- Source
- ActorSystem.scala
- Alphabetic
- By Inheritance
- ActorSystem
- ClassicActorSystemProvider
- ActorRefFactory
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ActorSystem()
Abstract Value Members
- abstract def /(name: Iterable[String]): ActorPath
Construct a path below the application guardian to be used with ActorSystem#actorSelection.
- abstract def /(name: String): ActorPath
Construct a path below the application guardian to be used with ActorSystem#actorSelection.
- abstract def actorOf(props: Props, name: String): ActorRef
Create new actor as child of this context with the given name, which must not be null, empty or start with “$”.
Create new actor as child of this context with the given name, which must not be null, empty or start with “$”. If the given name is already in use, an
InvalidActorNameException
is thrown.See pekko.actor.Props for details on how to obtain a
Props
object.- Definition Classes
- ActorRefFactory
- Exceptions thrown
UnsupportedOperationException
if invoked on an ActorSystem that uses a custom user guardianpekko.ConfigurationException
if deployment, dispatcher or mailbox configuration is wrongpekko.actor.InvalidActorNameException
if the given name is invalid or already in use
- abstract def actorOf(props: Props): ActorRef
Create new actor as child of this context and give it an automatically generated name (currently similar to base64-encoded integer count, reversed and with “$” prepended, may change in the future).
Create new actor as child of this context and give it an automatically generated name (currently similar to base64-encoded integer count, reversed and with “$” prepended, may change in the future).
See pekko.actor.Props for details on how to obtain a
Props
object.- Definition Classes
- ActorRefFactory
- Exceptions thrown
UnsupportedOperationException
if invoked on an ActorSystem that uses a custom user guardianpekko.ConfigurationException
if deployment, dispatcher or mailbox configuration is wrong
- abstract def classicSystem: ActorSystem
Allows access to the classic
org.apache.pekko.actor.ActorSystem
even fororg.apache.pekko.actor.typed.ActorSystem[_]
s.Allows access to the classic
org.apache.pekko.actor.ActorSystem
even fororg.apache.pekko.actor.typed.ActorSystem[_]
s.- Definition Classes
- ClassicActorSystemProvider
- abstract def deadLetters: ActorRef
Actor reference where messages are re-routed to which were addressed to stopped or non-existing actors.
Actor reference where messages are re-routed to which were addressed to stopped or non-existing actors. Delivery to this actor is done on a best effort basis and hence not strictly guaranteed.
- implicit abstract def dispatcher: ExecutionContextExecutor
Default dispatcher as configured.
Default dispatcher as configured. This dispatcher is used for all actors in the actor system which do not have a different dispatcher configured explicitly. Importing this member will place the default MessageDispatcher in scope.
- Definition Classes
- ActorSystem → ActorRefFactory
- abstract def dispatchers: Dispatchers
Helper object for looking up configured dispatchers.
- abstract def eventStream: EventStream
Main event bus of this actor system, used for example for logging.
- abstract def extension[T <: Extension](ext: ExtensionId[T]): T
Returns the payload that is associated with the provided extension throws an IllegalStateException if it is not registered.
Returns the payload that is associated with the provided extension throws an IllegalStateException if it is not registered. This method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution
- abstract def getWhenTerminated: CompletionStage[Terminated]
Returns a CompletionStage which will be completed after the ActorSystem has been terminated and termination hooks have been executed.
Returns a CompletionStage which will be completed after the ActorSystem has been terminated and termination hooks have been executed. If you registered any callback with ActorSystem#registerOnTermination, the returned CompletionStage from this method will not complete until all the registered callbacks are finished. 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. - abstract def guardian: InternalActorRef
Parent of all children created by this interface.
Parent of all children created by this interface.
INTERNAL API
- Attributes
- protected
- Definition Classes
- ActorRefFactory
- abstract def hasExtension(ext: ExtensionId[_ <: Extension]): Boolean
Returns whether the specified extension is already registered, this method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution
- abstract def log: LoggingAdapter
Convenient logging adapter for logging to the ActorSystem#eventStream.
- abstract def logConfiguration(): Unit
Log the configuration.
- abstract def lookupRoot: InternalActorRef
INTERNAL API
INTERNAL API
- Attributes
- protected
- Definition Classes
- ActorRefFactory
- abstract def mailboxes: Mailboxes
Helper object for looking up configured mailbox types.
- abstract def name: String
The name of this actor system, used to distinguish multiple ones within the same JVM & class loader.
- abstract def provider: ActorRefProvider
INTERNAL API
INTERNAL API
- Attributes
- protected
- Definition Classes
- ActorRefFactory
- abstract def registerExtension[T <: Extension](ext: ExtensionId[T]): T
Registers the provided extension and creates its payload, if this extension isn't already registered This method has putIfAbsent-semantics, this method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution
- abstract def registerOnTermination(code: Runnable): Unit
Java API: Register a block of code (callback) to run after ActorSystem.terminate has been issued and all actors in this actor system have been stopped.
Java API: Register a block of code (callback) to run after ActorSystem.terminate has been issued and all actors in this actor system have been stopped. Multiple code blocks may be registered by calling this method multiple times. The callbacks will be run sequentially in reverse order of registration, i.e. last registration is run first. Note that ActorSystem will not terminate until all the registered callbacks are finished.
Throws a RejectedExecutionException if the System has already been terminated or if termination has been initiated.
- abstract def registerOnTermination[T](code: => T): Unit
Register a block of code (callback) to run after ActorSystem.terminate has been issued and all actors in this actor system have been stopped.
Register a block of code (callback) to run after ActorSystem.terminate has been issued and all actors in this actor system have been stopped. Multiple code blocks may be registered by calling this method multiple times. The callbacks will be run sequentially in reverse order of registration, i.e. last registration is run first. Note that ActorSystem will not terminate until all the registered callbacks are finished.
Throws a RejectedExecutionException if the System has already been terminated or if termination has been initiated.
Scala API
- abstract def scheduler: Scheduler
Light-weight scheduler for running asynchronous tasks after some deadline in the future.
Light-weight scheduler for running asynchronous tasks after some deadline in the future. Not terribly precise but cheap.
- abstract def settings: Settings
The core settings extracted from the supplied configuration.
- abstract def stop(actor: ActorRef): Unit
Stop the actor pointed to by the given pekko.actor.ActorRef; this is an asynchronous operation, i.e.
Stop the actor pointed to by the given pekko.actor.ActorRef; this is an asynchronous operation, i.e. involves a message send. If this method is applied to the
self
reference from inside an Actor then that Actor is guaranteed to not process any further messages after this call; please note that the processing of the current message will continue, this method does not immediately terminate this actor.- Definition Classes
- ActorRefFactory
- abstract def systemImpl: ActorSystemImpl
INTERNAL API
INTERNAL API
- Attributes
- protected
- Definition Classes
- ActorRefFactory
- abstract def terminate(): Future[Terminated]
Terminates this actor system by running CoordinatedShutdown with reason CoordinatedShutdown.ActorSystemTerminateReason.
Terminates this actor system by running CoordinatedShutdown with reason CoordinatedShutdown.ActorSystemTerminateReason.
If
pekko.coordinated-shutdown.run-by-actor-system-terminate
is configured tooff
it will not runCoordinatedShutdown
, but theActorSystem
and 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) and then execute all registered termination handlers (see ActorSystem#registerOnTermination). Be careful to not schedule any operations on completion of the returned future using the dispatcher of this actor system as it will have been shut down before the future completes.
- abstract def whenTerminated: Future[Terminated]
Returns a Future which will be completed after the ActorSystem has been terminated and termination hooks have been executed.
Returns a Future which will be completed after the ActorSystem has been terminated and termination hooks have been executed. If you registered any callback with ActorSystem#registerOnTermination, the returned Future from this method will not complete until all the registered callbacks are finished. 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.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- Implicit
- This member is added by an implicit conversion from ActorSystem toany2stringadd[ActorSystem] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
- def ->[B](y: B): (ActorSystem, B)
- Implicit
- This member is added by an implicit conversion from ActorSystem toArrowAssoc[ActorSystem] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def actorSelection(path: ActorPath): ActorSelection
Construct an pekko.actor.ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally).
Construct an pekko.actor.ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally). No attempt is made to verify the existence of any part of the supplied path, it is recommended to send a message and gather the replies in order to resolve the matching set of actors.
- Definition Classes
- ActorRefFactory
- def actorSelection(path: String): ActorSelection
Construct an pekko.actor.ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally).
Construct an pekko.actor.ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally). No attempt is made to verify the existence of any part of the supplied path, it is recommended to send a message and gather the replies in order to resolve the matching set of actors.
- Definition Classes
- ActorRefFactory
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def child(child: String): ActorPath
Java API: Create a new child actor path.
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def descendant(names: Iterable[String]): ActorPath
Java API: Recursively create a descendant’s path by appending all child names.
- def ensuring(cond: (ActorSystem) => Boolean, msg: => Any): ActorSystem
- Implicit
- This member is added by an implicit conversion from ActorSystem toEnsuring[ActorSystem] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: (ActorSystem) => Boolean): ActorSystem
- Implicit
- This member is added by an implicit conversion from ActorSystem toEnsuring[ActorSystem] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean, msg: => Any): ActorSystem
- Implicit
- This member is added by an implicit conversion from ActorSystem toEnsuring[ActorSystem] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- def ensuring(cond: Boolean): ActorSystem
- Implicit
- This member is added by an implicit conversion from ActorSystem toEnsuring[ActorSystem] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def getDispatcher: ExecutionContextExecutor
Java API: Default dispatcher as configured.
Java API: Default dispatcher as configured. This dispatcher is used for all actors in the actor system which do not have a different dispatcher configured explicitly. Importing this member will place the default MessageDispatcher in scope.
- def getEventStream: EventStream
Java API: Main event bus of this actor system, used for example for logging.
- def getScheduler: Scheduler
Java API: Light-weight scheduler for running asynchronous tasks after some deadline in the future.
Java API: Light-weight scheduler for running asynchronous tasks after some deadline in the future. Not terribly precise but cheap.
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val startTime: Long
Start-up time in milliseconds since the epoch.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def uptime: Long
Up-time of this actor system in seconds.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @Deprecated
- Deprecated
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from ActorSystem toStringFormat[ActorSystem] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (ActorSystem, B)
- Implicit
- This member is added by an implicit conversion from ActorSystem toArrowAssoc[ActorSystem] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.