Avis
Avis

Reputation: 506

Some of the Actor messages are missing --AKKA FSM

Here is the sample code flow:

class FSMActor{
  when(Idle) {
    case Event(Start, Uninitialized) =>
    case Event(InitMap(inMap), t @ EvaluteRuleMap(v, c)) =>
      logger.info(s"State = $stateName, Event = Event(_, InitMap(inMap))")
      goto(EVALRule) using t.copy(ruleMap = inMap)
  }
  when(EVALRule) {
    case Event(RowMap(m), t @ EvaluteRuleMap(v, c)) =>
    logger.debug("input row map m " + m)
    **if ( <somecondition> ) {  // If comment this if-else block, I could see rowMaps being received.
      logger.debug(s"Moving to State Trigger x=$x")
      goto(TriggerRule) using t.copy(ruleMap = x.get)
    } else {
        logger.debug(s"staying in EVALRule, x = $x")
        stay
    }**
  }

  when(TriggerRule) {
    case Event(_, _) => ....
  }
 }
}

When the control in in "EVALRule" state, It will keep receiving streams maps(RowMap) and based on some computation, it moves to trigger rule.

Unfortunately for some weird reason, some of the incoming RowMaps are not being received at "case Event(RowMap(m), t @ EvaluteRuleMap(v, c)) =>" and If I comment the code bock (bolded in the above code) then I could see all incoming rowmaps being received. Could anyone let me know why is so? I've been trying to find the cause but couldn't get it to.
Appreciate your help, thanks.

Upvotes: 0

Views: 445

Answers (2)

Avis
Avis

Reputation: 506

There was some issue with message handling in the code itself, we debugged it and fixed the issue, now its working seamlessly.

Upvotes: -1

Ravi Kiran
Ravi Kiran

Reputation: 1139

When if ( <somecondition> ) is true, you are moving to the TriggerRule state. In that state you are looking for messages of type EVENT instead of Event (all caps). So the message is not handled by the FSM.

In general, when missing messages in FSM, the best way to debug is to write a whenUnhandled block with a log/print statement to see what messages are not handled by the states you have defined.

Upvotes: 0

Related Questions