I created an FSM with Akka. However, my FSM doesn't only get messages passed that are relevant for its FSM state. Its children may also pass ActorRef
s up to it, which my FSM should then pass further up to its parent. Since FSMs in Akka are (naturally) also actors, I would like to override receive
to catch those ActorRefs
. However, doing that broke the FSM functionality of the actor. What's the proper way to handle a situation like this?
Asked
Active
Viewed 195 times
1

typeduke
- 6,494
- 6
- 25
- 34
-
1Just to mention that Akka-FSM has many disadvantages: https://github.com/alexandru/scala-best-practices/blob/master/sections/5-actors.md#55-should-not-use-akka-fsm – dk14 Oct 16 '16 at 04:51
1 Answers
2
Messages that are not relevant for any FSM state can be handled in whenUnhandled
:
whenUnhandled {
case Event(someActorRef: ActorRef, _) =>
context.parent ! someActorRef
stay()
}
Though, overriding receive
should, afaik, work, too.

Sascha Kolberg
- 7,092
- 1
- 31
- 37