public interface ActorContext<T>
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:
- send a finite number of messages to other Actors it knows - create a finite number of Actors - designate the behavior for the next message
In Akka the first capability is accessed by using the !
or tell
method
on an ActorRef
, the second is provided by spawn(akka.typed.Props<U>, java.lang.String)
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 DeathWatch
and timed message scheduling.
Modifier and Type | Method and Description |
---|---|
akka.actor.ActorRef |
actorOf(akka.actor.Props props)
Create an untyped child Actor from the given
Props under a randomly chosen name. |
akka.actor.ActorRef |
actorOf(akka.actor.Props props,
java.lang.String name)
Create an untyped child Actor from the given
Props and with the given name. |
scala.Option<ActorRef<scala.runtime.Nothing$>> |
child(java.lang.String name)
The named child Actor if it is alive.
|
scala.collection.Iterable<ActorRef<scala.runtime.Nothing$>> |
children()
The list of child Actors created by this Actor during its lifetime that
are still alive, in no particular order.
|
scala.concurrent.ExecutionContextExecutor |
executionContext()
This Actor’s execution context.
|
Props<T> |
props()
The
Props from which this Actor was created. |
<U> akka.actor.Cancellable |
schedule(scala.concurrent.duration.FiniteDuration delay,
ActorRef<U> target,
U msg)
Schedule the sending of the given message to the given target Actor after
the given time period has elapsed.
|
ActorRef<T> |
self()
The identity of this Actor, bound to the lifecycle of this Actor instance.
|
void |
setReceiveTimeout(scala.concurrent.duration.Duration d)
Schedule the sending of a
ReceiveTimeout notification in case no other
message is received during the given period of time. |
<U> ActorRef<U> |
spawn(Props<U> props,
java.lang.String name)
Create a child Actor from the given
Props and with the given name. |
<U> ActorRef<U> |
spawnAdapter(scala.Function1<U,T> f)
Create a child actor that will wrap messages such that other Actor’s
protocols can be ingested by this Actor.
|
<U> ActorRef<U> |
spawnAnonymous(Props<U> props)
Create a child Actor from the given
Props under a randomly chosen name. |
boolean |
stop(ActorRef<scala.runtime.Nothing$> child)
Force the child Actor under the given name to terminate after it finishes
processing its current message.
|
ActorSystem<scala.runtime.Nothing$> |
system()
The
ActorSystem to which this Actor belongs. |
akka.actor.ActorRef |
unwatch(akka.actor.ActorRef other)
Revoke the registration established by
watch . |
<U> ActorRef<U> |
unwatch(ActorRef<U> other)
Revoke the registration established by
watch . |
akka.actor.ActorRef |
watch(akka.actor.ActorRef other)
Register for
Terminated notification once the Actor identified by the
given ActorRef terminates. |
<U> ActorRef<U> |
watch(ActorRef<U> other)
Register for
Terminated notification once the Actor identified by the
given ActorRef terminates. |
ActorRef<T> self()
ActorRef
.ActorSystem<scala.runtime.Nothing$> system()
ActorSystem
to which this Actor belongs.scala.collection.Iterable<ActorRef<scala.runtime.Nothing$>> children()
scala.Option<ActorRef<scala.runtime.Nothing$>> child(java.lang.String name)
name
- (undocumented)<U> ActorRef<U> spawnAnonymous(Props<U> props)
Props
under a randomly chosen name.
It is good practice to name Actors wherever practical.props
- (undocumented)<U> ActorRef<U> spawn(Props<U> props, java.lang.String name)
Props
and with the given name.props
- (undocumented)name
- (undocumented)akka.actor.ActorRef actorOf(akka.actor.Props props)
Props
under a randomly chosen name.
It is good practice to name Actors wherever practical.props
- (undocumented)akka.actor.ActorRef actorOf(akka.actor.Props props, java.lang.String name)
Props
and with the given name.props
- (undocumented)name
- (undocumented)boolean stop(ActorRef<scala.runtime.Nothing$> child)
child
- (undocumented)ActorRef
points to a current child Actor<U> ActorRef<U> watch(ActorRef<U> other)
Terminated
notification once the Actor identified by the
given ActorRef
terminates. This notification is also generated when the
ActorSystem
to which the referenced Actor belongs is declared as
failed (e.g. in reaction to being unreachable).other
- (undocumented)akka.actor.ActorRef watch(akka.actor.ActorRef other)
Terminated
notification once the Actor identified by the
given ActorRef
terminates. This notification is also generated when the
ActorSystem
to which the referenced Actor belongs is declared as
failed (e.g. in reaction to being unreachable).other
- (undocumented)<U> ActorRef<U> unwatch(ActorRef<U> other)
watch
. A Terminated
notification will not subsequently be received for the referenced Actor.other
- (undocumented)akka.actor.ActorRef unwatch(akka.actor.ActorRef other)
watch
. A Terminated
notification will not subsequently be received for the referenced Actor.other
- (undocumented)void setReceiveTimeout(scala.concurrent.duration.Duration d)
ReceiveTimeout
notification in case no other
message is received during the given period of time. The timeout starts anew
with each received message. Provide Duration.Undefined
to switch off this
mechanism.d
- (undocumented)<U> akka.actor.Cancellable schedule(scala.concurrent.duration.FiniteDuration delay, ActorRef<U> target, U msg)
Cancellable
cancel
on the returned
handle.delay
- (undocumented)target
- (undocumented)msg
- (undocumented)scala.concurrent.ExecutionContextExecutor executionContext()
Future
combinators.<U> ActorRef<U> spawnAdapter(scala.Function1<U,T> f)
f
- (undocumented)