Package org.apache.pekko.actor.typed
Interface ActorRef<T>
-
- All Superinterfaces:
java.lang.Comparable<ActorRef<?>>
,RecipientRef<T>
,java.io.Serializable
- All Known Subinterfaces:
ActorRefImpl<T>
- All Known Implementing Classes:
ActorSystem
public interface ActorRef<T> extends RecipientRef<T>, java.lang.Comparable<ActorRef<?>>, java.io.Serializable
An ActorRef is the identity or address of an Actor instance. It is valid only during the Actor’s lifetime and allows messages to be sent to that Actor instance. Sending a message to an Actor that has terminated before receiving the message will lead to that message being discarded; such messages are delivered to theDeadLetter
channel of thepekko.event.EventStream
on a best effort basis (i.e. this delivery is not reliable).Not for user extension
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ActorRef.ActorRefOps<T>
static class
ActorRef.ActorRefOps$
-
Nested classes/interfaces inherited from interface org.apache.pekko.actor.typed.RecipientRef
RecipientRef.RecipientRefOps<T>, RecipientRef.RecipientRefOps$
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <U extends T>
ActorRef<U>narrow()
Narrow the type of thisActorRef
, which is always a safe operation.ActorPath
path()
The hierarchical path name of the referenced Actor.void
tell(T msg)
Send a message to the Actor referenced by this ActorRef using *at-most-once* messaging semantics.<U> ActorRef<U>
unsafeUpcast()
Unsafe utility method for widening the type accepted by this ActorRef; provided to avoid having to useasInstanceOf
on the full reference type, which would unfortunately also work on non-ActorRefs.java.lang.Object
writeReplace()
-
-
-
Method Detail
-
tell
void tell(T msg)
Send a message to the Actor referenced by this ActorRef using *at-most-once* messaging semantics.- Specified by:
tell
in interfaceRecipientRef<T>
-
narrow
<U extends T> ActorRef<U> narrow()
Narrow the type of thisActorRef
, which is always a safe operation.
-
unsafeUpcast
<U> ActorRef<U> unsafeUpcast()
Unsafe utility method for widening the type accepted by this ActorRef; provided to avoid having to useasInstanceOf
on the full reference type, which would unfortunately also work on non-ActorRefs. Use it with caution,it may cause aClassCastException
when you send a message to the widenedActorRef[U
].
-
path
ActorPath path()
The hierarchical path name of the referenced Actor. The lifecycle of the ActorRef is fully contained within the lifecycle of thepekko.actor.ActorPath
and more than one Actor instance can exist with the same path at different points in time, but not concurrently.
-
writeReplace
java.lang.Object writeReplace() throws java.io.ObjectStreamException
- Throws:
java.io.ObjectStreamException
-
-