Can you share some code. I just tried to reproduce it based on your
explanation and it all works for me (see code below), but may be I am
missing something.

Cheers
Oleg
=========

import akka.actor.Actor

import akka.actor.ActorSystem

import akka.actor.FSM

import akka.actor.FSM.SubscribeTransitionCallBack

import akka.actor.Props


sealed trait State

case object RED extends State

case object GREEN extends State

case class Data

case class AlternateColor


object FsmActor extends App {

  val system = ActorSystem("akka")

  val fsmActor = system.actorOf(Props[FsmActor], "FSMActor")

  val monitor = system.actorOf(Props(classOf[StateMonitor]), "StateMonitor")

  fsmActor ! SubscribeTransitionCallBack(monitor)

  (1 to 10) foreach { i => fsmActor ! AlternateColor }

}

class StateMonitor extends Actor {

  def receive = {

    x => {

        x match {

          case _ => println("MONITOR RECEIVED: " + x)

        }

      }

  }

}

class FsmActor extends Actor with FSM[State, Data] {

  override def preStart(): Unit = {

    println("hello prestart")

  }

  startWith(RED, Data())

  when(RED) {

    case Event(AlternateColor, _) => goto(GREEN)

  }

  when(GREEN) {

    case Event(AlternateColor, _) => goto(RED)

  }

  onTransition {

    case RED -> GREEN => println("I am RED, going GREEN")

    case GREEN -> RED => println("I am GREEN, going RED")

  }

  initialize

}


On Tue, Jan 28, 2014 at 3:38 PM, Vadim Bobrov <vadimbob...@gmail.com> wrote:

> Hi,
>
> I ran into this problem: when preStart is overriden (empty) for an FSM
> actor it stops sending CurrentState in response
> to SubscribeTransitionCallBack. Tried putting
>
> startWith
> initialize
>
> into preStart, still not getting CurrentState. What is the correct
> solution in this case? I am disabling preStart so I can customize recovery
> in Persistence module
>
> Thanks
> Vadim
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to