CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-typesafe-akka--akka-actor-2-11

Akka Actor provides the foundational Actor Model implementation for building concurrent, distributed, resilient and elastic applications with supervision hierarchies and location transparency.

Overview
Eval results
Files

actor-system.mddocs/

Actor System

The ActorSystem is the foundation of any Akka application, providing the runtime environment for actors and managing system-wide resources like configuration, scheduling, and event streams.

Capabilities

Actor System Creation

Factory methods for creating actor systems with various configuration options.

/**
 * Creates a new ActorSystem with default configuration
 * @return ActorSystem with name "default"
 */
def create(): ActorSystem

/**
 * Creates a new ActorSystem with specified name
 * @param name - System name for distinguishing multiple systems
 * @return Named ActorSystem
 */  
def create(name: String): ActorSystem

/**
 * Creates a new ActorSystem with custom configuration
 * @param name - System name
 * @param config - Typesafe Config for system settings
 * @return Configured ActorSystem
 */
def create(name: String, config: Config): ActorSystem

/**
 * Creates a new ActorSystem with classloader and execution context
 * @param name - System name
 * @param config - Configuration
 * @param classLoader - Custom class loader
 * @param defaultExecutionContext - Default execution context
 * @return Fully configured ActorSystem
 */
def create(
  name: String,
  config: Config,
  classLoader: ClassLoader,
  defaultExecutionContext: ExecutionContext
): ActorSystem

// Scala API variants
def apply(): ActorSystem
def apply(name: String): ActorSystem
def apply(name: String, config: Config): ActorSystem
def apply(name: String, setup: ActorSystemSetup): ActorSystem
def apply(name: String, bootstrapSetup: BootstrapSetup): ActorSystem
def apply(name: String, config: Option[Config], classLoader: Option[ClassLoader], defaultExecutionContext: Option[ExecutionContext]): ActorSystem

// Java API with setup
def create(name: String, setups: ActorSystemSetup): ActorSystem
def create(name: String, bootstrapSetup: BootstrapSetup): ActorSystem

Usage Examples:

import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory

// Default system
val system = ActorSystem.create()

// Named system
val system = ActorSystem.create("MySystem")

// With custom configuration
val config = ConfigFactory.parseString("""
  akka {
    log-config-on-start = true
    actor {
      default-dispatcher {
        throughput = 10
      }
    }
  }
""")
val system = ActorSystem.create("ConfiguredSystem", config)

Top-Level Actor Creation

Methods for creating actors at the top level of the actor hierarchy.

/**
 * Create a top-level actor with generated name
 * @param props - Props configuration for the actor
 * @return ActorRef to the created actor
 */
def actorOf(props: Props): ActorRef

/**
 * Create a named top-level actor
 * @param props - Props configuration for the actor
 * @param name - Unique name within this system
 * @return ActorRef to the created actor
 */
def actorOf(props: Props, name: String): ActorRef

/**
 * Stop a top-level actor
 * @param actor - ActorRef to stop
 */
def stop(actor: ActorRef): Unit

Actor Selection

Methods for selecting actors by path patterns, supporting wildcards and hierarchical lookup.

/**
 * Select actors by string path
 * @param path - Actor path pattern (supports wildcards)
 * @return ActorSelection for the path
 */
def actorSelection(path: String): ActorSelection

/**
 * Select actors by ActorPath object
 * @param path - Structured actor path
 * @return ActorSelection for the path
 */
def actorSelection(path: ActorPath): ActorSelection

/**
 * Create path relative to system guardian  
 * @param name - Child name
 * @return ActorPath for /user/name
 */
def /(name: String): ActorPath

Usage Examples:

// Select by path string
val selection = system.actorSelection("/user/myActor")
val wildcard = system.actorSelection("/user/*")
val descendant = system.actorSelection("/user/parent/*/child")

// Resolve selection to ActorRef
import akka.util.Timeout
import scala.concurrent.duration._
implicit val timeout = Timeout(5.seconds)

val futureRef: Future[ActorRef] = selection.resolveOne()

System Termination

Graceful shutdown methods with lifecycle management and cleanup.

/**
 * Initiate graceful shutdown of the system
 * @return Future that completes when system is terminated
 */
def terminate(): Future[Terminated]

/**
 * Future that completes when system termination is complete
 * @return Future[Terminated] for monitoring shutdown
 */
def whenTerminated: Future[Terminated]

/**
 * Java API - CompletionStage for system termination
 * @return CompletionStage that completes when terminated
 */
def getWhenTerminated: CompletionStage[Terminated]

/**
 * Register callback to run during system termination
 * @param code - Callback code to execute
 */
def registerOnTermination[T](code: => T): Unit

/**
 * Java API - Register Runnable for termination
 * @param code - Runnable to execute during shutdown
 */
def registerOnTermination(code: Runnable): Unit

System Components Access

Access to core system components for advanced configuration and monitoring.

/**
 * System name for distinguishing multiple systems in same JVM
 */
def name: String

/**
 * System configuration settings
 */
def settings: Settings

/**
 * Task scheduler for delayed/periodic execution
 */
def scheduler: Scheduler

/**
 * Default message dispatcher (ExecutionContext)
 */  
def dispatcher: ExecutionContextExecutor

/**
 * Dispatcher factory and registry
 */
def dispatchers: Dispatchers

/**
 * Mailbox type factory and registry
 */
def mailboxes: Mailboxes

/**
 * Event publication/subscription bus
 */
def eventStream: EventStream

/**
 * Dead letter office for undeliverable messages
 */
def deadLetters: ActorRef

/**
 * System logging adapter
 */
def log: LoggingAdapter

/**
 * System startup time in milliseconds since epoch
 */
val startTime: Long

/**
 * System uptime in seconds
 */
def uptime: Long

Extension Management

Methods for managing ActorSystem extensions for modular functionality.

/**
 * Register extension and get instance
 * @param ext - ExtensionId for the extension
 * @return Extension instance
 */
def registerExtension[T <: Extension](ext: ExtensionId[T]): T

/**
 * Get existing extension instance
 * @param ext - ExtensionId for the extension
 * @return Extension instance
 * @throws IllegalStateException if not registered
 */
def extension[T <: Extension](ext: ExtensionId[T]): T

/**
 * Check if extension is registered
 * @param ext - ExtensionId to check
 * @return true if extension is registered
 */
def hasExtension(ext: ExtensionId[_ <: Extension]): Boolean

Types

/**
 * Marker for successful system termination
 */
sealed trait Terminated extends Serializable

/**
 * Actor system configuration settings
 */
class Settings(
  classLoader: ClassLoader,
  cfg: Config,
  final val name: String,
  val setup: ActorSystemSetup
) {
  final val config: Config
  final val LogLevel: String
  final val Loggers: immutable.Seq[String]
  final val CreationTimeout: Timeout
  final val DefaultVirtualNodesFactor: Int
}

/**
 * Bootstrap configuration for actor system creation
 */
final class BootstrapSetup private (
  val classLoader: Option[ClassLoader] = None,
  val config: Option[Config] = None,
  val defaultExecutionContext: Option[ExecutionContext] = None,
  val actorRefProvider: Option[ProviderSelection] = None
) extends Setup {
  def withClassloader(classLoader: ClassLoader): BootstrapSetup
  def withConfig(config: Config): BootstrapSetup
  def withDefaultExecutionContext(executionContext: ExecutionContext): BootstrapSetup
  def withActorRefProvider(name: ProviderSelection): BootstrapSetup
}

Install with Tessl CLI

npx tessl i tessl/maven-com-typesafe-akka--akka-actor-2-11

docs

actor-system.md

actors-props.md

fsm.md

index.md

messaging-references.md

patterns-utilities.md

scheduling-timers.md

supervision.md

tile.json