Interface Stash
-
- All Superinterfaces:
Actor,RequiresMessageQueue<DequeBasedMessageQueueSemantics>,StashSupport,UnrestrictedStash
- All Known Subinterfaces:
AbstractPersistentActorLike,AsyncWriteProxy,AtLeastOnceDelivery,AtLeastOnceDeliveryLike,Eventsourced,PersistenceStash,PersistentActor
- All Known Implementing Classes:
AbstractActorWithStash,AbstractFSMWithStash,AbstractPersistentActor,AbstractPersistentActorWithAtLeastOnceDelivery,AbstractPersistentActorWithTimers,JournalPerfSpec.BenchActor,PersistencePluginProxy,PersistentShardCoordinator
public interface Stash extends UnrestrictedStash, RequiresMessageQueue<DequeBasedMessageQueueSemantics>
TheStashtrait enables an actor to temporarily stash away messages that can not or should not be handled using the actor's current behavior. Example:class ActorWithProtocol extends Actor with Stash { def receive = { case "open" => unstashAll() context.become({ case "write" => // do writing... case "close" => unstashAll() context.unbecome() case msg => stash() }, discardOld = false) case "done" => // done case msg => stash() } }Note that the
Stashtrait 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 extendsRequiresMessageQueue[DequeBasedMessageQueueSemantics]. You can override the default mailbox provided whenDequeBasedMessageQueueSemanticsare 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
Stashthat also enforces unboundedness of the deque seeUnboundedStash. For aStashthat does not enforce any mailbox type seeUnrestrictedStash.Note that the
Stashtrait must be mixed into (a subclass of) theActortrait before any trait/class that overrides thepreRestartcallback. This means it's not possible to writeActor with MyActor with StashifMyActoroverridespreRestart.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
-
Method Summary
-
Methods inherited from interface akka.actor.Actor
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preStart, receive, self, sender, supervisorStrategy, unhandled
-
Methods inherited from interface akka.actor.StashSupport
actorCell, akka$actor$StashSupport$_setter_$mailbox_$eq, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, theStash_$eq, unstash, unstashAll, unstashAll
-
Methods inherited from interface akka.actor.UnrestrictedStash
postStop, preRestart, super$postStop, super$preRestart
-
-