Class ActorSystem
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 Props
for details on props
):
system.ActorOf(props, "name");
system.ActorOf(props);
system.ActorOf(Props.Create(typeof(MyActor)), "name");
system.ActorOf(Props.Create(() => new MyActor(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.
Inherited Members
Namespace: Akka.Actor
Assembly: Akka.dll
Syntax
public abstract class ActorSystem : IActorRefFactory, IDisposable
Properties
| Improve this Doc View SourceDeadLetters
Gets the dead letters.
Declaration
public abstract IActorRef DeadLetters { get; }
Property Value
Type | Description |
---|---|
IActorRef | The dead letters. |
Dispatchers
Gets the dispatchers.
Declaration
public abstract Dispatchers Dispatchers { get; }
Property Value
Type | Description |
---|---|
Dispatchers | The dispatchers. |
EventStream
Gets the event stream.
Declaration
public abstract EventStream EventStream { get; }
Property Value
Type | Description |
---|---|
EventStream | The event stream. |
IgnoreRef
Declaration
public abstract IActorRef IgnoreRef { get; }
Property Value
Type | Description |
---|---|
IActorRef |
Log
Gets the log
Declaration
public abstract ILoggingAdapter Log { get; }
Property Value
Type | Description |
---|---|
ILoggingAdapter |
Mailboxes
Gets the mailboxes.
Declaration
public abstract Mailboxes Mailboxes { get; }
Property Value
Type | Description |
---|---|
Mailboxes | The mailboxes. |
Name
Gets the name of this system.
Declaration
public abstract string Name { get; }
Property Value
Type | Description |
---|---|
String | The name. |
Scheduler
Gets the scheduler.
Declaration
public abstract IScheduler Scheduler { get; }
Property Value
Type | Description |
---|---|
IScheduler | The scheduler. |
Serialization
Gets the serialization.
Declaration
public abstract Serialization Serialization { get; }
Property Value
Type | Description |
---|---|
Serialization | The serialization. |
Settings
Gets the settings.
Declaration
public abstract Settings Settings { get; }
Property Value
Type | Description |
---|---|
Settings | The settings. |
StartTime
Start-up time since the epoch.
Declaration
public TimeSpan StartTime { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Uptime
Up-time of this actor system.
Declaration
public TimeSpan Uptime { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
WhenTerminated
Returns a task which will be completed after the ActorSystem has been
terminated and termination hooks have been executed. Be careful to not schedule any
operations on the dispatcher
of this actor system as it will have been shut down
before this task completes.
Declaration
public abstract Task WhenTerminated { get; }
Property Value
Type | Description |
---|---|
Task |
Methods
| Improve this Doc View SourceActorOf(Props, String)
Interface IActorRefFactory
Declaration
public abstract IActorRef ActorOf(Props props, string name = null)
Parameters
Type | Name | Description |
---|---|---|
Props | props | The props used to create this actor. |
String | name | Optional. The name of this actor. |
Returns
Type | Description |
---|---|
IActorRef | A newly created actor that uses the specified props. |
Exceptions
Type | Condition |
---|---|
InvalidActorNameException | Thrown if the given name is invalid or already in use |
ConfigurationException | Thrown if deployment, dispatcher or mailbox configuration is wrong |
ActorSelection(ActorPath)
Interface IActorRefFactory
Declaration
public abstract ActorSelection ActorSelection(ActorPath actorPath)
Parameters
Type | Name | Description |
---|---|---|
ActorPath | actorPath | The actor path used as the base of the actor selection. |
Returns
Type | Description |
---|---|
ActorSelection | An ActorSelection based on the specified |
ActorSelection(String)
Interface IActorRefFactory
Declaration
public abstract ActorSelection ActorSelection(string actorPath)
Parameters
Type | Name | Description |
---|---|---|
String | actorPath | The actor path used as the base of the actor selection. |
Returns
Type | Description |
---|---|
ActorSelection | An ActorSelection based on the specified |
Create(String)
Creates a new ActorSystem with the specified name.
Declaration
public static ActorSystem Create(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the actor system to create. The name must be uri friendly.
|
Returns
Type | Description |
---|---|
ActorSystem | A newly created actor system with the given name. |
Create(String, BootstrapSetup)
Shortcut for creating a new actor system with the specified name and settings.
Declaration
public static ActorSystem Create(string name, BootstrapSetup setup)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the actor system to create. The name must be uri friendly.
|
BootstrapSetup | setup | The bootstrap setup used to help programmatically initialize the ActorSystem. |
Returns
Type | Description |
---|---|
ActorSystem | A newly created actor system with the given name and configuration. |
Create(String, ActorSystemSetup)
Shortcut for creating a new actor system with the specified name and settings.
Declaration
public static ActorSystem Create(string name, ActorSystemSetup setup)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the actor system to create. The name must be uri friendly.
|
ActorSystemSetup | setup | The bootstrap setup used to help programmatically initialize the ActorSystem. |
Returns
Type | Description |
---|---|
ActorSystem | A newly created actor system with the given name and configuration. |
Create(String, Config)
Creates a new ActorSystem with the specified name and configuration.
Declaration
public static ActorSystem Create(string name, Config config)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the actor system to create. The name must be uri friendly.
|
Config | config | The configuration used to create the actor system |
Returns
Type | Description |
---|---|
ActorSystem | A newly created actor system with the given name and configuration. |
Dispose()
Declaration
public void Dispose()
GetExtension(IExtensionId)
Retrieves the specified extension that is registered to this actor system.
Declaration
public abstract object GetExtension(IExtensionId extensionId)
Parameters
Type | Name | Description |
---|---|---|
IExtensionId | extensionId | The extension to retrieve |
Returns
Type | Description |
---|---|
Object | The specified extension registered to this actor system |
GetExtension<T>()
Retrieves an extension with the specified type that is registered to this actor system.
Declaration
public abstract T GetExtension<T>()
where T : class, IExtension
Returns
Type | Description |
---|---|
T | The specified extension registered to this actor system |
Type Parameters
Name | Description |
---|---|
T | The type of extension to retrieve |
HasExtension(Type)
Determines whether this actor system has an extension with the specified type.
Declaration
public abstract bool HasExtension(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type of the extension being queried |
Returns
Type | Description |
---|---|
Boolean |
|
HasExtension<T>()
Determines whether this actor system has the specified extension.
Declaration
public abstract bool HasExtension<T>()
where T : class, IExtension
Returns
Type | Description |
---|---|
Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of the extension being queried |
RegisterExtension(IExtensionId)
Registers the specified extension with this actor system.
Declaration
public abstract object RegisterExtension(IExtensionId extension)
Parameters
Type | Name | Description |
---|---|---|
IExtensionId | extension | The extension to register with this actor system |
Returns
Type | Description |
---|---|
Object | The extension registered with this actor system |
RegisterOnTermination(Action)
Registers a block of code (callback) to run after ActorSystem.shutdown 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.
Declaration
public abstract void RegisterOnTermination(Action code)
Parameters
Type | Name | Description |
---|---|---|
Action | code | The code to run |
Exceptions
Type | Condition |
---|---|
Exception | This exception is thrown if the system has already shut down or if shutdown has been initiated. |
Stop(IActorRef)
Stops the specified actor permanently.
Declaration
public abstract void Stop(IActorRef actor)
Parameters
Type | Name | Description |
---|---|---|
IActorRef | actor | The actor to stop |
Remarks
This method has no effect if the actor is already stopped.
Terminate()
If akka.coordinated-shutdown.run-by-actor-system-terminate
is configured to off
it will not run CoordinatedShutdown
, but the ActorSystem
and its actors
will still be terminated.
Terminates this actor system. This will stop the guardian actor, which in turn will recursively stop all its child actors, then the system guardian (below which the logging actors reside) and the execute all registered termination handlers (RegisterOnTermination(Action)).
Be careful to not schedule any operations on completion of the returned task using the dispatcher
of this actor system as it will have been shut down before the task completes.
Declaration
public abstract Task Terminate()
Returns
Type | Description |
---|---|
Task | A Task that will complete once the actor system has finished terminating and all actors are stopped. |
TryGetExtension(Type, out Object)
Tries to retrieve an extension with the specified type.
Declaration
public abstract bool TryGetExtension(Type extensionType, out object extension)
Parameters
Type | Name | Description |
---|---|---|
Type | extensionType | The type of extension to retrieve |
Object | extension | The extension that is retrieved if successful |
Returns
Type | Description |
---|---|
Boolean |
|
TryGetExtension<T>(out T)
Tries to retrieve an extension with the specified type
Declaration
public abstract bool TryGetExtension<T>(out T extension)
where T : class, IExtension
Parameters
Type | Name | Description |
---|---|---|
T | extension | The extension that is retrieved if successful |
Returns
Type | Description |
---|---|
Boolean |
|
Type Parameters
Name | Description |
---|---|
T | The type of extension to retrieve |