Trait

akka.actor.typed.scaladsl

ActorContext

Related Doc: package scaladsl

Permalink

trait ActorContext[T] extends typed.ActorContext[T]

An Actor is given by the combination of a Behavior and a context in which this behavior is executed. As per the Actor Model an Actor can perform the following actions when processing a message:

In Akka the first capability is accessed by using the ! or tell method on an ActorRef, the second is provided by ActorContext#spawn and the third is implicit in the signature of Behavior in that the next behavior is always returned from the message processing logic.

An ActorContext in addition provides access to the Actor’s own identity (“self”), the ActorSystem it is part of, methods for querying the list of child Actors it created, access to Terminated and timed message scheduling.

Not for user extension.

Self Type
ActorContext[T] with javadsl.ActorContext[T]
Annotations
@DoNotInherit() @ApiMayChange()
Source
ActorContext.scala
Linear Supertypes
typed.ActorContext[T], AnyRef, Any
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ActorContext
  2. ActorContext
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def asJava: javadsl.ActorContext[T]

    Permalink

    Get the javadsl of this ActorContext.

    Get the javadsl of this ActorContext.

    This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

    Definition Classes
    ActorContextActorContext
  2. abstract def asScala: ActorContext[T]

    Permalink

    Get the scaladsl of this ActorContext.

    Get the scaladsl of this ActorContext.

    Definition Classes
    ActorContext
  3. abstract def ask[Req, Res](otherActor: ActorRef[Req])(createRequest: (ActorRef[Res]) ⇒ Req)(mapResponse: (Try[Res]) ⇒ T)(implicit responseTimeout: Timeout, classTag: ClassTag[Res]): Unit

    Permalink

    Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.

    Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.

    The interaction has a timeout (to avoid a resource leak). If the timeout hits without any response it will be passed as a Failure(java.util.concurrent.TimeoutException) to the mapResponse function (this is the only "normal" way a Failure is passed to the function).

    For other messaging patterns with other actors, see ActorContext#messageAdapter.

    This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

    Req

    The request protocol, what the other actor accepts

    Res

    The response protocol, what the other actor sends back

    createRequest

    A function that creates a message for the other actor, containing the provided ActorRef[Res] that the other actor can send a message back through.

    mapResponse

    Transforms the response from the otherActor into a message this actor understands. Should be a pure function but is executed inside the actor when the response arrives so can safely touch the actor internals. If this function throws an exception it is just as if the normal message receiving logic would throw.

  4. abstract def cancelReceiveTimeout(): Unit

    Permalink

    Cancel the sending of receive timeout notifications.

    Cancel the sending of receive timeout notifications.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  5. abstract def child(name: String): Option[ActorRef[Nothing]]

    Permalink

    The named child Actor if it is alive.

    The named child Actor if it is alive.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  6. abstract def children: Iterable[ActorRef[Nothing]]

    Permalink

    The list of child Actors created by this Actor during its lifetime that are still alive, in no particular order.

    The list of child Actors created by this Actor during its lifetime that are still alive, in no particular order.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  7. implicit abstract def executionContext: ExecutionContextExecutor

    Permalink

    This Actor’s execution context.

    This Actor’s execution context. It can be used to run asynchronous tasks like scala.concurrent.Future operators.

    This field is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  8. abstract def log: Logger

    Permalink

    An actor specific logger

    An actor specific logger

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  9. abstract def messageAdapter[U](f: (U) ⇒ T)(implicit arg0: ClassTag[U]): ActorRef[U]

    Permalink

    Create a message adapter that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor.

    Create a message adapter that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor.

    You can register several message adapters for different message classes. It's only possible to have one message adapter per message class to make sure that the number of adapters are not growing unbounded if registered repeatedly. That also means that a registered adapter will replace an existing adapter for the same message class.

    A message adapter will be used if the message class matches the given class or is a subclass thereof. The registered adapters are tried in reverse order of their registration order, i.e. the last registered first.

    A message adapter (and the returned ActorRef) has the same lifecycle as this actor. It's recommended to register the adapters in a top level Behaviors.setup or constructor of MutableBehavior but it's possible to register them later also if needed. Message adapters don't have to be stopped since they consume no resources other than an entry in an internal Map and the number of adapters are bounded since it's only possible to have one per message class. * The function is running in this actor and can safely access state of it.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  10. abstract def schedule[U](delay: FiniteDuration, target: ActorRef[U], msg: U): Cancellable

    Permalink

    Schedule the sending of the given message to the given target Actor after the given time period has elapsed.

    Schedule the sending of the given message to the given target Actor after the given time period has elapsed. The scheduled action can be cancelled by invoking akka.actor.Cancellable#cancel on the returned handle.

    This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  11. abstract def self: ActorRef[T]

    Permalink

    The identity of this Actor, bound to the lifecycle of this Actor instance.

    The identity of this Actor, bound to the lifecycle of this Actor instance. An Actor with the same name that lives before or after this instance will have a different ActorRef.

    This field is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  12. abstract def setReceiveTimeout(d: FiniteDuration, msg: T): Unit

    Permalink

    Schedule the sending of a notification in case no other message is received during the given period of time.

    Schedule the sending of a notification in case no other message is received during the given period of time. The timeout starts anew with each received message. Use cancelReceiveTimeout to switch off this mechanism.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  13. abstract def spawn[U](behavior: Behavior[U], name: String, props: Props = Props.empty): ActorRef[U]

    Permalink

    Create a child Actor from the given akka.actor.typed.Behavior and with the given name.

    Create a child Actor from the given akka.actor.typed.Behavior and with the given name.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  14. abstract def spawnAnonymous[U](behavior: Behavior[U], props: Props = Props.empty): ActorRef[U]

    Permalink

    Create a child Actor from the given akka.actor.typed.Behavior under a randomly chosen name.

    Create a child Actor from the given akka.actor.typed.Behavior under a randomly chosen name. It is good practice to name Actors wherever practical.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  15. abstract def stop[U](child: ActorRef[U]): Unit

    Permalink

    Force the child Actor under the given name to terminate after it finishes processing its current message.

    Force the child Actor under the given name to terminate after it finishes processing its current message. Nothing happens if the ActorRef is a child that is already stopped.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

    Exceptions thrown

    IllegalArgumentException if the given actor ref is not a direct child of this actor

  16. abstract def system: ActorSystem[Nothing]

    Permalink

    The ActorSystem to which this Actor belongs.

    The ActorSystem to which this Actor belongs.

    This field is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  17. abstract def unwatch[U](other: ActorRef[U]): Unit

    Permalink

    Revoke the registration established by watch.

    Revoke the registration established by watch. A Terminated notification will not subsequently be received for the referenced Actor.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  18. abstract def watch[U](other: ActorRef[U]): Unit

    Permalink

    Register for akka.actor.typed.Terminated notification once the Actor identified by the given ActorRef terminates.

    Register for akka.actor.typed.Terminated notification once the Actor identified by the given ActorRef terminates. This message is also sent when the watched actor is on a node that has been removed from the cluster when using akka-cluster or has been marked unreachable when using akka-remote directly

    watch is idempotent if it is not mixed with watchWith.

    It will fail with an IllegalStateException if the same subject was watched before using watchWith. To clear the termination message, unwatch first.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

  19. abstract def watchWith[U](other: ActorRef[U], msg: T): Unit

    Permalink

    Register for termination notification with a custom message once the Actor identified by the given ActorRef terminates.

    Register for termination notification with a custom message once the Actor identified by the given ActorRef terminates. This message is also sent when the watched actor is on a node that has been removed from the cluster when using akka-cluster or has been marked unreachable when using akka-remote directly.

    watchWith is idempotent if it is called with the same msg and not mixed with watch.

    It will fail with an IllegalStateException if the same subject was watched before using watch or watchWith with another termination message. To change the termination message, unwatch first.

    *Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as scala.concurrent.Future callbacks.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to any2stringadd[ActorContext[T]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (ActorContext[T], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to ArrowAssoc[ActorContext[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def ensuring(cond: (ActorContext[T]) ⇒ Boolean, msg: ⇒ Any): ActorContext[T]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to Ensuring[ActorContext[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  9. def ensuring(cond: (ActorContext[T]) ⇒ Boolean): ActorContext[T]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to Ensuring[ActorContext[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: Boolean, msg: ⇒ Any): ActorContext[T]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to Ensuring[ActorContext[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean): ActorContext[T]

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to Ensuring[ActorContext[T]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def formatted(fmtstr: String): String

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to StringFormat[ActorContext[T]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  16. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  17. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  23. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. def [B](y: B): (ActorContext[T], B)

    Permalink
    Implicit information
    This member is added by an implicit conversion from ActorContext[T] to ArrowAssoc[ActorContext[T]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from typed.ActorContext[T]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from ActorContext[T] to any2stringadd[ActorContext[T]]

Inherited by implicit conversion StringFormat from ActorContext[T] to StringFormat[ActorContext[T]]

Inherited by implicit conversion Ensuring from ActorContext[T] to Ensuring[ActorContext[T]]

Inherited by implicit conversion ArrowAssoc from ActorContext[T] to ArrowAssoc[ActorContext[T]]

Ungrouped