hi,

I am Nicola (not Christian),

I created a github repo for you:

https://github.com/pic/akkaTheHutt

you have three classes:

FiniteStateMachine ( no persistence, extends Actor )
AlmostPersistentFSM ( extends Processor but no use of Persistent )
PersistentFSM ( persistence )

The only difference between FiniteStateMachine and AlmostPersistentFSM is 
that the first extends Actor, the second extends Processor,
the only difference between AlmostPersistentFSM and PersistentFSM is that 
the second actually uses Persistent messages.

You have tests for the three classes (FiniteStateMachineSpec, ...) which 
are practically the same.
If you try to run the tests you will see that:
FiniteStateMachineSpes -> OK
AlmostPersistentFSMSpec -> red
PersistentFSMSpec -> red

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Also I have a new problem. I write it here but maybe a new thread would be 
more appropriate.

There are also three objects that you can run

FiniteStateMachineSpes -> Main
AlmostPersistentFSMSpec -> AlmostPersistentMain
PersistentFSMSpec -> PersistentMain

If you try to run PersistentMain the first time, it looks OK, journal is 
written, etc., etc.
Then you kill the process, and you run it a second time.
akka-persistence is not able to restore the state because PersistentImpl 
messages are sent (instead of Persistent).
You see in the log:

[DEBUG] [05/06/2014 13:15:42.274] [default-akka.actor.default-dispatcher-7] 
[akka://default/user/persistentUnderTest] processing 
Event(PersistentImpl(Done(List(゜⋓想춌鋋)),1,/user/persistentUnderTest,false,List(),Actor[akka://default/user/persistentUnderTest#161253413]),List())
 
from Actor[akka://default/user/persistentUnderTest#161253413]
[WARN] [05/06/2014 13:15:42.275] [default-akka.actor.default-dispatcher-7] 
[akka://default/user/persistentUnderTest] unhandled event 
PersistentImpl(Done(List(゜⋓想춌鋋)),1,/user/persistentUnderTest,false,List(),Actor[akka://default/user/persistentUnderTest#161253413])
 
in state waiting
[DEBUG] [05/06/2014 13:15:42.275] [default-akka.actor.default-dispatcher-7] 
[akka://default/user/persistentUnderTest] processing 
Event(PersistentImpl(Done(List(ꍎ穽ᮯ适ࡣ, 
゜⋓想춌鋋)),2,/user/persistentUnderTest,false,List(),Actor[akka://default/user/persistentUnderTest#161253413]),List())
 
from Actor[akka://default/user/persistentUnderTest#161253413]
[WARN] [05/06/2014 13:15:42.275] [default-akka.actor.default-dispatcher-7] 
[akka://default/user/persistentUnderTest] unhandled event 
PersistentImpl(Done(List(ꍎ穽ᮯ适ࡣ, 
゜⋓想춌鋋)),2,/user/persistentUnderTest,false,List(),Actor[akka://default/user/persistentUnderTest#161253413])
 
in state waiting
...

What am I doing wrong here?

Thanks,
Nicola


On Monday, May 5, 2014 10:24:31 AM UTC+2, Akka Team wrote:
>
> Hi Christian,
>
> Do you have a small reproducible test case that exposes the problem? If 
> you do, please share so we can look into the possible issue.
>
> -Endre
>
>
> On Sun, May 4, 2014 at 2:07 PM, Nicola Piccinini 
> <picc...@gmail.com<javascript:>
> > wrote:
>
>> Yes, http://doc.akka.io/docs/akka/snapshot/scala/persistence.
>>> html#state-machines
>>>
>>
>> thank you for the pointer.
>>
>> The problem was that I had overwritten preStart, with something like:
>>
>> super.preStart()
>> self ! Message
>>
>> and that did not play well with Processor.
>> Since it is probably not a good idea, I have refactored my FSM and I am 
>> not overwriting #preStart anymore.
>>
>> Now, in "normal" condition, my Processor-FSM runs fine but I have a new 
>> problem.
>>
>> I have some tests for the FSM, I  have just updated to last scalatest 
>> version to be sure to use the most up to date stuff:
>>
>> "com.typesafe.akka" %% "akka-actor" % "2.3.2",
>> "com.typesafe.akka" %% "akka-persistence-experimental" % "2.3.2",
>>
>> "org.scalatest" %% "scalatest" % "2.1.5" % "test",
>> "com.typesafe.akka" %% "akka-testkit" % "2.3.2" % "test",
>> "org.mockito" % "mockito-core" % "1.9.5" % "test"
>>
>> One test is a mixin between FunSpec and akka TestKit and looks like:
>>
>> >-------------
>> val brain = mock[SchedulerBrain]
>> when(brain.timeoutFor).thenReturn(Map[Symbol, 
>> FiniteDuration]().withDefaultValue(50.seconds))
>> when(brain.schedule(Mock.gate, Map())).thenReturn(Map("123" -> 
>> "/collector/123"))
>> fsmRef = createFsmRef(brain)
>> Thread.sleep(100)
>> assert(fsmRef.stateName === Waiting)
>> assert(fsmRef.stateData === Map("123" -> "/collector/123"))
>> verify(brain).schedule(Mock.gate, Map())
>> -------------<
>>
>> When my FSM is an Actor (not a Processor), the test run successfully and 
>> this is the log:
>>
>> [DEBUG] [05/04/2014 13:57:35.228] [default-scheduler-1] 
>> [akka://default/user/$$a] transition 
>> org.peach.moma.schedulers.CollectorsScheduler$Waiting$@7a7d0e26 -> 
>> org.peach.moma.schedulers.CollectorsScheduler$Scheduling$@62170848
>> [DEBUG] [05/04/2014 13:57:35.229] [default-scheduler-1] 
>> [akka://default/user/$$a] processing Event(Scheduled(Map(123 -> 
>> /collector/123)),Map()) from TestActor[akka://default/user/$$a]
>> [DEBUG] [05/04/2014 13:57:35.230] [default-scheduler-1] 
>> [akka://default/user/$$a] transition 
>> org.peach.moma.schedulers.CollectorsScheduler$Scheduling$@62170848 -> 
>> org.peach.moma.schedulers.CollectorsScheduler$Waiting$@7a7d0e26
>>
>> When my FSM is a Processor, then I have this assertion error:
>> Map() did not equal Map("123" -> "/collector/123")
>> and no logs related to the FSM transitions (???).
>>
>> The only difference is about extending Actor or Processor, I am not yet 
>> using any Persistent message so the behaviour should not vary, I think.
>>
>> I have another test related to that FSM and also it is green with Actor, 
>> red with Processor, so it really seems that persistence is affecting tests 
>> in a bad way.
>>
>> Any idea?
>> Thanks
>>
>>>   -- 
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> 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+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Akka Team
> Typesafe - The software stack for applications that scale
> Blog: letitcrash.com
> Twitter: @akkateam
>  

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      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/d/optout.

Reply via email to