FSM StateTimeout after actor stop
Hi.
After stopping actor that using FSM with stateTimeout in state, actor is stops, but FSM trying to send messages to dead actor.
this happens at actual version 2.2.3
here is some code:
After stopping actor that using FSM with stateTimeout in state, actor is stops, but FSM trying to send messages to dead actor.
this happens at actual version 2.2.3
here is some code:
object MyApp {
lazy val system = ActorSystem("TestSystem")
def main(args: Array[String]) {
val actor = system.actorOf(Props[MyActor])
actor ! "Some message"
Thread.sleep(10000)
}
}
sealed trait MyState
sealed trait MyData
class MyActor extends Actor with ActorLogging with FSM[MyState, MyData] {
case object StateOne extends MyState
case object NoData extends MyData
startWith(StateOne, NoData)
when(StateOne, 5.seconds) {
case Event(m, _) =>
log.info(s"Received message '${m}'")
context.stop(self)
stay()
case Event(StateTimeout, _) =>
log.info("StateTimeout")
stay()
}
}
Leave a comment