Interface Stash

All Superinterfaces:
Actor, RequiresMessageQueue<DequeBasedMessageQueueSemantics>, StashSupport, UnrestrictedStash
All Known Subinterfaces:
AsyncWriteProxy, AtLeastOnceDelivery, Creators.ActWithStash, Eventsourced, EventsourcedProcessor, PersistentActor, PersistentView, Processor, ProcessorImpl, Recovery, View
All Known Implementing Classes:
AbstractActorWithStash, AbstractEventsourcedProcessor, AbstractPersistentActor, AbstractPersistentActorWithAtLeastOnceDelivery, AbstractPersistentView, AbstractProcessor, AbstractView, ClusterClient, ClusterSingletonProxy, InmemJournal, JournalPerfSpec.BenchActor, RequestReader, RequestWriter, ShardCoordinator, SharedLeveldbJournal, UntypedActorWithStash, UntypedEventsourcedProcessor, UntypedPersistentActor, UntypedPersistentActorWithAtLeastOnceDelivery, UntypedPersistentView, UntypedProcessor, UntypedView

public interface Stash
extends UnrestrictedStash, RequiresMessageQueue<DequeBasedMessageQueueSemantics>

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.

    class ActorWithProtocol extends Actor with Stash {
      def receive = {
        case "open" ⇒
            case "write" ⇒ // do writing...
            case "close" ⇒
            case msg ⇒ stash()
          }, discardOld = false)
        case "done" ⇒ // done
        case msg    ⇒ stash()

Note that the Stash trait can only be used together with actors that have a deque-based mailbox. By default Stash based actors request a Deque based mailbox since the stash trait extends RequiresMessageQueue[DequeBasedMessageQueueSemantics]. You can override the default mailbox provided when DequeBasedMessageQueueSemantics are requested via config:

    akka.actor.mailbox.requirements {
      "akka.dispatch.BoundedDequeBasedMessageQueueSemantics" = your-custom-mailbox
Alternatively, you can add your own requirement marker to the actor and configure a mailbox type to be used for your marker.

For a Stash that also enforces unboundedness of the deque see UnboundedStash. For a Stash that does not enforce any mailbox type see UnrestrictedStash.

Note that the Stash trait must be mixed into (a subclass of) the Actor trait before any trait/class that overrides the preRestart callback. This means it's not possible to write Actor with MyActor with Stash if MyActor overrides preRestart.

Nested Class Summary
Nested classes/interfaces inherited from interface akka.actor.Actor
Method Summary
Methods inherited from interface akka.actor.UnrestrictedStash
postStop, preRestart
Methods inherited from interface akka.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preStart, receive, self, sender, supervisorStrategy, unhandled
Methods inherited from interface akka.actor.StashSupport
actorCell, capacity, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, theStash, unstash, unstashAll, unstashAll