I am trying to build an Akka actor FSM in java that times out after a certain time if it remains in the Idle state. I am using this (https://doc.akka.io/docs/akka/2.5/fsm.html) as a reference. Below is the sample code that I am using
public class TestActorFSM extends AbstractLoggingFSM<State, Data> {
{
startWith(Idle, Uninitialized);
when(Idle, Duration.create(10, SECONDS),
matchEventEquals(StateTimeout(), Todo.class,
(event, todo) -> {
log().info("Timeout received");
return goTo(Expired);
}));
initialize();
}
Actor is instantiated in Idle state and if it stays in that state for 10 seconds it should go to expired state. After 10 seconds, I do receive an event but it wouldn’t go into the handler and throws a warning with below message. “unhandled event StateTimeout in state Idle”
Can anyone please explain, what am i doing wrong here?