Suppose there are messages in the mailbox. Is it possible to suspend the Actor from processing the messages and resume it at a later point without holding the thread.
Thanks, Ravi
Suppose there are messages in the mailbox. Is it possible to suspend the Actor from processing the messages and resume it at a later point without holding the thread.
Thanks, Ravi
Akka provides a way of changing the behavior of an actor using
context.become()
andcontext.unbecome()
. It also provides a way tostash()
andunstash()
your message once you have changed your behavior.The idea would be to
become()
a new behavior that basically does nothing (like suspended) but stash the messages. Once a certain condition is met, the actorunbecome()
s andunstashAll()
the messages to put them back again in the mailbox and start processing them again.You can find a good example in the Akka docs (look for Stash): http://doc.akka.io/docs/akka/snapshot/scala/actors.html