akka.actor

ActorRef

trait ActorRef extends ActorRefShared with Comparable[ActorRef]

ActorRef is an immutable and serializable handle to an Actor.

Create an ActorRef for an Actor by using the factory method on the Actor object.

Here is an example on how to create an actor with a default constructor.

  import Actor._

  val actor = actorOf[MyActor]
  actor.start()
  actor ! message
  actor.stop()

You can also create and start actors like this:

  val actor = actorOf[MyActor].start()

Here is an example on how to create an actor with a non-default constructor.

  import Actor._

  val actor = actorOf(new MyActor(...))
  actor.start()
  actor ! message
  actor.stop()

Self Type
ActorRef with ScalaActorRef
Linear Supertypes
Comparable[ActorRef], ActorRefShared, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ActorRef
  2. Comparable
  3. ActorRefShared
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Abstract Value Members

  1. def actorInstance : AtomicReference[Actor]

    Attributes
    protected[akka] abstract
  2. def dispatcher : MessageDispatcher

    Get the dispatcher for this actor.

    Get the dispatcher for this actor.

    Attributes
    abstract
  3. def dispatcher_= (md: MessageDispatcher): Unit

    Sets the dispatcher for this actor.

    Sets the dispatcher for this actor. Needs to be invoked before the actor is started.

    Attributes
    abstract
  4. def getFaultHandler (): FaultHandlingStrategy

    Attributes
    abstract
  5. def getLifeCycle (): LifeCycle

    Attributes
    abstract
  6. def handleTrapExit (dead: ActorRef, reason: Throwable): Unit

    Attributes
    protected[akka] abstract
  7. def invoke (messageHandle: MessageInvocation): Unit

    Attributes
    protected[akka] abstract
  8. def link (actorRef: ActorRef): Unit

    Links an other actor to this actor.

    Links an other actor to this actor. Links are unidirectional and means that a the linking actor will receive a notification if the linked actor has crashed.

    If the 'trapExit' member field of the 'faultHandler' has been set to at contain at least one exception class then it will 'trap' these exceptions and automatically restart the linked actors according to the restart strategy defined by the 'faultHandler'.

    Attributes
    abstract
  9. def linkedActors : Map[Uuid, ActorRef]

    Returns an unmodifiable Java Map containing the linked actors, please note that the backing map is thread-safe but not immutable

    Returns an unmodifiable Java Map containing the linked actors, please note that the backing map is thread-safe but not immutable

    Attributes
    abstract
  10. def mailbox : AnyRef

    Attributes
    protected[akka] abstract
  11. def mailbox_= (value: AnyRef): AnyRef

    Attributes
    protected[akka] abstract
  12. def postMessageToMailbox (message: Any, senderOption: Option[ActorRef]): Unit

    Attributes
    protected[akka] abstract
  13. def postMessageToMailboxAndCreateFutureResultWithTimeout [T] (message: Any, timeout: Long, senderOption: Option[ActorRef], senderFuture: Option[CompletableFuture[T]]): CompletableFuture[T]

    Attributes
    protected[akka] abstract
  14. def registerSupervisorAsRemoteActor : Option[Uuid]

    Attributes
    protected[akka] abstract
  15. def restart (reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit

    Attributes
    protected[akka] abstract
  16. def restartLinkedActors (reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit

    Attributes
    protected[akka] abstract
  17. def setFaultHandler (handler: FaultHandlingStrategy): Unit

    Akka Java API.

    Akka Java API.

    A faultHandler defines what should be done when a linked actor signals an error.

    Can be one of:

    getContext().setFaultHandler(new AllForOneStrategy(new Class[]{Throwable.class},maxNrOfRetries, withinTimeRange));
    
    Or:
    getContext().setFaultHandler(new OneForOneStrategy(new Class[]{Throwable.class},maxNrOfRetries, withinTimeRange));
    

    Attributes
    abstract
  18. def setLifeCycle (lifeCycle: LifeCycle): Unit

    Akka Java API.

    Akka Java API.

    A lifeCycle defines whether the actor will be stopped on error (Temporary) or if it can be restarted (Permanent)

    Can be one of:

    import static akka.config.Supervision.*;

    getContext().setLifeCycle(permanent());
    
    Or:
    getContext().setLifeCycle(temporary());
    

    Attributes
    abstract
  19. def start (): ActorRef

    Starts up the actor and its message queue.

    Starts up the actor and its message queue.

    Attributes
    abstract
  20. def startLink (actorRef: ActorRef): Unit

    Atomically start and link an actor.

    Atomically start and link an actor.

    Attributes
    abstract
  21. def stop (): Unit

    Shuts down the actor its dispatcher and message queue.

    Shuts down the actor its dispatcher and message queue.

    Attributes
    abstract
  22. def supervisor : Option[ActorRef]

    Returns the supervisor, if there is one.

    Returns the supervisor, if there is one.

    Attributes
    abstract
  23. def supervisor_= (sup: Option[ActorRef]): Unit

    Attributes
    protected[akka] abstract
  24. def unlink (actorRef: ActorRef): Unit

    Unlink the actor.

    Unlink the actor.

    Attributes
    abstract
  25. def actorClass : Class[_ <: akka.actor.Actor]

    Returns the class for the Actor instance that is managed by the ActorRef.

    Returns the class for the Actor instance that is managed by the ActorRef.

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Will be removed without replacement, doesn't make any sense to have in the face of become and unbecome

  26. def actorClassName : String

    Returns the class name for the Actor instance that is managed by the ActorRef.

    Returns the class name for the Actor instance that is managed by the ActorRef.

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Will be removed without replacement, doesn't make any sense to have in the face of become and unbecome

  27. def homeAddress : Option[InetSocketAddress]

    Returns on which node this actor lives if None it lives in the local ActorRegistry

    Returns on which node this actor lives if None it lives in the local ActorRegistry

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Remoting will become fully transparent in the future

  28. def spawn (clazz: Class[_ <: akka.actor.Actor]): ActorRef

    Atomically create (from actor class) and start an actor.

    Atomically create (from actor class) and start an actor.

    To be invoked from within the actor itself.

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Will be removed after 1.1, use Actor.actorOf instead

  29. def spawnLink (clazz: Class[_ <: akka.actor.Actor]): ActorRef

    Atomically create (from actor class), link and start an actor.

    Atomically create (from actor class), link and start an actor.

    To be invoked from within the actor itself.

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Will be removed after 1.1, use use Actor.remote.actorOf instead and then link on success

  30. def spawnLinkRemote (clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long): ActorRef

    Atomically create (from actor class), make it remote, link and start an actor.

    Atomically create (from actor class), make it remote, link and start an actor.

    To be invoked from within the actor itself.

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Will be removed after 1.1, client managed actors will be removed

  31. def spawnRemote (clazz: Class[_ <: akka.actor.Actor], hostname: String, port: Int, timeout: Long): ActorRef

    Atomically create (from actor class), make it remote and start an actor.

    Atomically create (from actor class), make it remote and start an actor.

    To be invoked from within the actor itself.

    Attributes
    abstract
    Annotations
    @deprecated
    Deprecated

    Will be removed after 1.1, client managed actors will be removed

Concrete Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. var _status : StatusType

    Attributes
    protected[this]
  7. var _uuid : Uuid

    Attributes
    protected[akka]
  8. def actor : Actor

    Attributes
    protected[akka]
  9. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  10. def channel : Channel[Any]

    Abstraction for unification of sender and senderFuture for later reply

  11. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  12. def compareTo (other: ActorRef): Int

    Comparison only takes uuid into account.

    Comparison only takes uuid into account.

    Definition Classes
    ActorRef → Comparable
  13. var currentMessage : MessageInvocation

    This is a reference to the message currently being processed by the actor

    This is a reference to the message currently being processed by the actor

    Attributes
    protected[akka]
  14. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  15. def equals (that: Any): Boolean

    Definition Classes
    ActorRef → AnyRef → Any
  16. def exit (): Unit

    Shuts down the actor its dispatcher and message queue.

    Shuts down the actor its dispatcher and message queue. Alias for 'stop'.

  17. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. def forward (message: AnyRef, sender: ActorRef): Unit

    Akka Java API.

    Akka Java API.

    Forwards the message specified to this actor and preserves the original sender of the message

  19. def getChannel : Channel[Any]

    Java API.

    Java API.

    Abstraction for unification of sender and senderFuture for later reply

  20. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef
  21. def getDispatcher (): MessageDispatcher

  22. def getId (): String

  23. def getLinkedActors (): Map[Uuid, ActorRef]

    Java API.

    Java API.

    Returns an unmodifiable Java Map containing the linked actors, please note that the backing map is thread-safe but not immutable

  24. def getMailboxSize (): Int

    Akka Java API.

    Akka Java API.

    Returns the mailbox size.

  25. def getReceiveTimeout (): Option[Long]

  26. def getSender (): Option[ActorRef]

    Akka Java API.

    Akka Java API.

    The reference sender Actor of the last received message. Is defined if the message was sent from another Actor, else None.

  27. def getSenderFuture (): Option[CompletableFuture[Any]]

    Akka Java API.

    Akka Java API.

    The reference sender future of the last received message. Is defined if the message was sent with sent with '!!' or '!!!', else None.

  28. def getSupervisor (): ActorRef

    Akka Java API.

    Akka Java API.

    Returns the supervisor, if there is one.

  29. def getUuid (): Uuid

    Returns the uuid for the actor.

  30. def hashCode (): Int

    Definition Classes
    ActorRef → AnyRef → Any
  31. var hotswap : Stack[PartialFunction[Any, Unit]]

    Holds the hot swapped partial function.

    Holds the hot swapped partial function.

    Attributes
    protected[akka]
  32. var id : String

    User overridable callback/setting.

    User overridable callback/setting.

    Identifier for actor, does not have to be a unique one. Default is the 'uuid'.

    This field is used for logging, AspectRegistry.actorsFor(id), identifier for remote actor in RemoteServer etc.But also as the identifier for persistence, which means that you can use a custom name to be able to retrieve the "correct" persisted state upon restart, remote restart etc.

  33. def isBeingRestarted : Boolean

    Is the actor being restarted?

  34. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  35. def isRunning : Boolean

    Is the actor running?

  36. def isShutdown : Boolean

    Is the actor shut down?

  37. def isUnstarted : Boolean

    Is the actor ever started?

  38. def mailboxSize : Int

    Returns the mailbox size.

  39. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  40. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  41. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  42. var receiveTimeout : Option[Long]

    User overridable callback/setting.

    User overridable callback/setting.

    Defines the default timeout for an initial receive invocation. When specified, the receive function should be able to handle a 'ReceiveTimeout' message.

  43. def replySafe (message: AnyRef): Boolean

    Akka Java API.

    Akka Java API.

    Use getContext().replySafe(..) to reply with a message to the original sender of the message currently being processed.

    Returns true if reply was sent, and false if unable to determine what to reply to.

  44. def replyUnsafe (message: AnyRef): Unit

    Akka Java API.

    Akka Java API.

    Use getContext().replyUnsafe(..) to reply with a message to the original sender of the message currently being processed.

    Throws an IllegalStateException if unable to determine what to reply to.

  45. def sendOneWay (message: AnyRef, sender: ActorRef): Unit

    Akka Java API.

    Akka Java API.

    Sends a one-way asynchronous message. E.g. fire-and-forget semantics.

    Allows you to pass along the sender of the message.

    actor.sendOneWay(message, context);
    

  46. def sendOneWay (message: AnyRef): Unit

    Akka Java API.

    Akka Java API.

    Sends a one-way asynchronous message. E.g. fire-and-forget semantics.

    actor.sendOneWay(message);
    

  47. def sendRequestReply (message: AnyRef, timeout: Long, sender: ActorRef): AnyRef

    Akka Java API.

    Akka Java API.

    Sends a message asynchronously and waits on a future for a reply message under the hood.

    It waits on the reply either until it receives it or until the timeout expires (which will throw an ActorTimeoutException). E.g. send-and-receive-eventually semantics.

    NOTE: Use this method with care. In most cases it is better to use 'sendOneWay' together with 'getContext().getSender()' to implement request/response message exchanges.

    If you are sending messages using sendRequestReply then you have to use getContext().reply(..) to send a reply message to the original sender. If not then the sender will block until the timeout expires.

  48. def sendRequestReply (message: AnyRef, sender: ActorRef): AnyRef

    Akka Java API.

    Akka Java API.

    See also

    sendRequestReply(message: AnyRef, timeout: Long, sender: ActorRef) Uses the default timeout of the Actor (setTimeout())

  49. def sendRequestReply (message: AnyRef): AnyRef

    Akka Java API.

    Akka Java API.

    See also

    sendRequestReply(message: AnyRef, timeout: Long, sender: ActorRef) Uses the default timeout of the Actor (setTimeout()) and omits the sender reference

  50. def sendRequestReplyFuture [T <: AnyRef] (message: AnyRef, timeout: Long, sender: ActorRef): Future[T]

    Akka Java API.

    Akka Java API.

    Sends a message asynchronously returns a future holding the eventual reply message.

    NOTE: Use this method with care. In most cases it is better to use 'sendOneWay' together with the 'getContext().getSender()' to implement request/response message exchanges.

    If you are sending messages using sendRequestReplyFuture then you have to use getContext().reply(..) to send a reply message to the original sender. If not then the sender will block until the timeout expires.

  51. def sendRequestReplyFuture [T <: AnyRef] (message: AnyRef, sender: ActorRef): Future[T]

    Akka Java API.

    Akka Java API.

    See also

    sendRequestReplyFuture(message: AnyRef, sender: ActorRef): Future[_] Uses the Actors default timeout (setTimeout())

  52. def sendRequestReplyFuture [T <: AnyRef] (message: AnyRef): Future[T]

    Akka Java API.

    Akka Java API.

    See also

    sendRequestReplyFuture(message: AnyRef, sender: ActorRef): Future[_] Uses the Actors default timeout (setTimeout()) and omits the sender

  53. def setDispatcher (dispatcher: MessageDispatcher): Unit

    Akka Java API.

    Akka Java API.

    The default dispatcher is the Dispatchers.globalExecutorBasedEventDrivenDispatcher. This means that all actors will share the same event-driven executor based dispatcher.

    You can override it so it fits the specific use-case that the actor is used for. See the akka.dispatch.Dispatchers class for the different dispatchers available.

    The default is also that all actors that are created and spawned from within this actor is sharing the same dispatcher as its creator.

  54. def setId (arg0: String): Unit

    User overridable callback/setting.

    User overridable callback/setting.

    Identifier for actor, does not have to be a unique one. Default is the 'uuid'.

    This field is used for logging, AspectRegistry.actorsFor(id), identifier for remote actor in RemoteServer etc.But also as the identifier for persistence, which means that you can use a custom name to be able to retrieve the "correct" persisted state upon restart, remote restart etc.

  55. def setReceiveTimeout (timeout: Long): Unit

    Akka Java API.

    Akka Java API.

    Defines the default timeout for an initial receive invocation. When specified, the receive function should be able to handle a 'ReceiveTimeout' message.

  56. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  57. def toString (): String

    Definition Classes
    ActorRef → AnyRef → Any
  58. def uuid : Uuid

    Returns the uuid for the actor.

    Returns the uuid for the actor.

    Definition Classes
    ActorRefActorRefShared
  59. def uuid_= (uid: Uuid): Unit

    Only for internal use.

    Only for internal use. UUID is effectively final.

    Attributes
    protected[akka]
  60. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  63. def getActorClass (): Class[_ <: akka.actor.Actor]

    Akka Java API.

    Akka Java API.

    Returns the class for the Actor instance that is managed by the ActorRef.

    Annotations
    @deprecated
    Deprecated

    Will be removed without replacement, doesn't make any sense to have in the face of become and unbecome

  64. def getActorClassName (): String

    Akka Java API.

    Akka Java API.

    Returns the class name for the Actor instance that is managed by the ActorRef.

    Annotations
    @deprecated
    Deprecated

    Will be removed without replacement, doesn't make any sense to have in the face of become and unbecome

  65. def getHomeAddress (): InetSocketAddress

    Java API.

    Java API.

    Annotations
    @deprecated
    Deprecated

    Remoting will become fully transparent in the future

  66. def getTimeout (): Long

    Annotations
    @deprecated
    Deprecated

    Will be replaced by implicit-scoped timeout on all methods that needs it, will default to timeout specified in config

  67. def isDefinedAt (message: Any): Boolean

    Is the actor able to handle the message passed in as arguments?

    Is the actor able to handle the message passed in as arguments?

    Annotations
    @deprecated
    Deprecated

    Will be removed without replacement, it's just not reliable in the face of become and unbecome

  68. def setTimeout (arg0: Long): Unit

    User overridable callback/setting.

    User overridable callback/setting.

    Defines the default timeout for '!!' and '!!!' invocations, e.g. the timeout for the future returned by the call to '!!' and '!!!'.

    Annotations
    @deprecated
    Deprecated

    Will be replaced by implicit-scoped timeout on all methods that needs it, will default to timeout specified in config

  69. var timeout : Long

    User overridable callback/setting.

    User overridable callback/setting.

    Defines the default timeout for '!!' and '!!!' invocations, e.g. the timeout for the future returned by the call to '!!' and '!!!'.

    Annotations
    @deprecated
    Deprecated

    Will be replaced by implicit-scoped timeout on all methods that needs it, will default to timeout specified in config

Inherited from Comparable[ActorRef]

Inherited from ActorRefShared

Inherited from AnyRef

Inherited from Any