Overridden callback.
Overridden callback. Prepends all messages in the stash to the mailbox and clears the stash. Must be called when overriding this method, otherwise stashed messages won't be propagated to DeadLetters when actor stops.
Overridden callback.
Overridden callback. Prepends all messages in the stash to the mailbox, clears the stash, stops all children and invokes the postStop() callback.
Adds the current message (the message that the actor received last) to the actor's stash.
Adds the current message (the message that the actor received last) to the actor's stash.
if the same message is stashed more than once
StashOverflowExceptionin case of a stash capacity violation
Prepends all messages in the stash to the mailbox, and then clears the stash.
Prepends all messages in the stash to the mailbox, and then clears the stash.
Messages from the stash are enqueued to the mailbox until the capacity of the
mailbox (if any) has been reached. In case a bounded mailbox overflows, a
MessageQueueAppendFailedException
is thrown.
The stash is guaranteed to be empty after calling unstashAll()
.
The
Stash
trait enables an actor to temporarily stash away messages that can not or should not be handled using the actor's current behavior.Example:
Note that the
Stash
trait can only be used together with actors that have a deque-based mailbox. Actors can be configured to use a deque-based mailbox using a configuration like the following (see the documentation on dispatchers on how to configure a custom dispatcher):Note that the
Stash
trait must be mixed into (a subclass of) theActor
trait before any trait/class that overrides thepreRestart
callback. This means it's not possible to writeActor with MyActor with Stash
ifMyActor
overridespreRestart
.