I would like to stash the received message and migrate the data after the success of the migration I change the behavior to execute the stashed command.
trait Actor { this: Stash with Actor =>
def executeCommands: Receive = {
case "OK" => sender ! "ok"
case _ => sender ! "false"
}
def migrateData(): Future[Unit Or Error] = Future.successful(Good(()))
override def receive: Receive ={
case _ =>
stash()
migrateData().map {
case Good(_) =>
context.become(executeCommands)
unstashAll()
case Bad(err) =>
unstashall()
sender ! err
} } }
I recive an exception `` AskTimeoutException
is that the recipient actor didn’t send a reply.
at akka.pattern.PromiseActorRef$.$anonfun$defaultOnTimeout$1(AskSupport.scala:646)
at akka.pattern.PromiseActorRef$.$anonfun$apply$1(AskSupport.scala:667)
at akka.actor.Scheduler$anon$7.run(Scheduler.scala:476)```