Interface AbstractActor.ActorContext
-
- All Superinterfaces:
ActorContext
,ActorRefFactory
,ClassicActorContextProvider
- Enclosing class:
- AbstractActor
public static interface AbstractActor.ActorContext extends ActorContext
The actor context - the view of the actor cell from the actor. Exposes contextual information for the actor and the current message.Not intended for public inheritance/implementation
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
become(AbstractActor.Receive behavior)
Changes the Actor's behavior to become the new 'Receive' handler.void
become(AbstractActor.Receive behavior, boolean discardOld)
Changes the Actor's behavior to become the new 'Receive' handler.void
cancelReceiveTimeout()
Cancel the sending of receive timeout notifications.java.util.Optional<ActorRef>
findChild(java.lang.String name)
Returns a reference to the named child if it exists.java.lang.Iterable<ActorRef>
getChildren()
Returns an unmodifiable Java Collection containing the linked actorsscala.concurrent.ExecutionContextExecutor
getDispatcher()
Returns the dispatcher (MessageDispatcher) that is used for this Actor.ActorRef
getParent()
Returns the supervisor of this actor.Props
getProps()
Retrieve the Props which were used to create this actor.java.time.Duration
getReceiveTimeout()
Gets the current receive timeout.ActorRef
getSelf()
The ActorRef representing this actorActorRef
getSender()
Returns the sender 'ActorRef' of the current message.ActorSystem
getSystem()
Returns the system this actor is running in.void
setReceiveTimeout(java.time.Duration timeout)
Defines the inactivity timeout after which the sending of apekko.actor.ReceiveTimeout
message is triggered.-
Methods inherited from interface org.apache.pekko.actor.ActorContext
become, become, child, children, dispatcher, parent, props, receiveTimeout, self, sender, setReceiveTimeout, system, unbecome, unwatch, watch, watchWith, writeObject
-
Methods inherited from interface org.apache.pekko.actor.ActorRefFactory
actorOf, actorOf, actorSelection, actorSelection, guardian, lookupRoot, provider, stop, systemImpl
-
Methods inherited from interface org.apache.pekko.actor.ClassicActorContextProvider
classicActorContext
-
-
-
-
Method Detail
-
become
void become(AbstractActor.Receive behavior)
Changes the Actor's behavior to become the new 'Receive' handler. Replaces the current behavior on the top of the behavior stack.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.
-
become
void become(AbstractActor.Receive behavior, boolean discardOld)
Changes the Actor's behavior to become the new 'Receive' handler. This method acts upon the behavior stack as follows:- if
discardOld = true
it will replace the top element (i.e. the current behavior) - ifdiscardOld = false
it will keep the current behavior and push the given one atopThe default of replacing the current behavior on the stack has been chosen to avoid memory leaks in case client code is written without consulting this documentation first (i.e. always pushing new behaviors and never issuing an
unbecome()
)*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.
-
cancelReceiveTimeout
void cancelReceiveTimeout()
Cancel the sending of receive timeout notifications.
-
findChild
java.util.Optional<ActorRef> findChild(java.lang.String name)
Returns a reference to the named child if it exists.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.
-
getChildren
java.lang.Iterable<ActorRef> getChildren()
Returns an unmodifiable Java Collection containing the linked actors*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.
-
getDispatcher
scala.concurrent.ExecutionContextExecutor getDispatcher()
Returns the dispatcher (MessageDispatcher) that is used for this Actor.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
andFuture
callbacks.
-
getParent
ActorRef getParent()
Returns the supervisor of this actor.Same as
parent()
.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.
-
getProps
Props getProps()
Retrieve the Props which were used to create this actor.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
andFuture
callbacks.
-
getReceiveTimeout
java.time.Duration getReceiveTimeout()
Gets the current receive timeout. When specified, the receive method should be able to handle apekko.actor.ReceiveTimeout
message.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
andFuture
callbacks.
-
getSelf
ActorRef getSelf()
The ActorRef representing this actorThis method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
andFuture
callbacks.
-
getSender
ActorRef getSender()
Returns the sender 'ActorRef' of the current message.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
andFuture
callbacks.
-
getSystem
ActorSystem getSystem()
Returns the system this actor is running in.Same as
system()
This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.
-
setReceiveTimeout
void setReceiveTimeout(java.time.Duration timeout)
Defines the inactivity timeout after which the sending of apekko.actor.ReceiveTimeout
message is triggered. When specified, the receive function should be able to handle apekko.actor.ReceiveTimeout
message. 1 millisecond is the minimum supported timeout.Please note that the receive timeout might fire and enqueue the
ReceiveTimeout
message right after another message was enqueued; hence it is '''not guaranteed''' that upon reception of the receive timeout there must have been an idle period beforehand as configured via this method.Once set, the receive timeout stays in effect (i.e. continues firing repeatedly after inactivity periods). Pass in
Duration.Undefined
to switch off this feature.Messages marked with
NotInfluenceReceiveTimeout
will not reset the timer. This can be useful whenReceiveTimeout
should be fired by external inactivity but not influenced by internal activity, e.g. scheduled tick messages.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
andFuture
callbacks.
-
-