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 voidbecome(AbstractActor.Receive behavior)Changes the Actor's behavior to become the new 'Receive' handler.voidbecome(AbstractActor.Receive behavior, boolean discardOld)Changes the Actor's behavior to become the new 'Receive' handler.voidcancelReceiveTimeout()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.ExecutionContextExecutorgetDispatcher()Returns the dispatcher (MessageDispatcher) that is used for this Actor.ActorRefgetParent()Returns the supervisor of this actor.PropsgetProps()Retrieve the Props which were used to create this actor.java.time.DurationgetReceiveTimeout()Gets the current receive timeout.ActorRefgetSelf()The ActorRef representing this actorActorRefgetSender()Returns the sender 'ActorRef' of the current message.ActorSystemgetSystem()Returns the system this actor is running in.voidsetReceiveTimeout(java.time.Duration timeout)Defines the inactivity timeout after which the sending of aReceiveTimeoutmessage is triggered.-
Methods inherited from interface akka.actor.ActorContext
become, become, child, children, dispatcher, parent, props, receiveTimeout, self, sender, setReceiveTimeout, system, unbecome, unwatch, watch, watchWith, writeObject
-
Methods inherited from interface akka.actor.ActorRefFactory
actorOf, actorOf, actorSelection, actorSelection, guardian, lookupRoot, provider, stop, systemImpl
-
Methods inherited from interface akka.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
CompletionStagecallbacks.
-
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 = trueit will replace the top element (i.e. the current behavior) - ifdiscardOld = falseit 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
CompletionStagecallbacks.
-
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
CompletionStagecallbacks.
-
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
CompletionStagecallbacks.
-
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
CompletionStageandFuturecallbacks.
-
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
CompletionStagecallbacks.
-
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
CompletionStageandFuturecallbacks.
-
getReceiveTimeout
java.time.Duration getReceiveTimeout()
Gets the current receive timeout. When specified, the receive method should be able to handle aReceiveTimeoutmessage.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStageandFuturecallbacks.
-
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
CompletionStageandFuturecallbacks.
-
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
CompletionStageandFuturecallbacks.
-
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
CompletionStagecallbacks.
-
setReceiveTimeout
void setReceiveTimeout(java.time.Duration timeout)
Defines the inactivity timeout after which the sending of aReceiveTimeoutmessage is triggered. When specified, the receive function should be able to handle aReceiveTimeoutmessage. 1 millisecond is the minimum supported timeout.Please note that the receive timeout might fire and enqueue the
ReceiveTimeoutmessage 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.Undefinedto switch off this feature.Messages marked with
NotInfluenceReceiveTimeoutwill not reset the timer. This can be useful whenReceiveTimeoutshould 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
CompletionStageandFuturecallbacks.
-
-