I think I found a solution.
*isPersistent is false during receiving SnapshotOffer, but true during 
receiving other persisted events from journal.*
So a solution is to add "if isPersistent" beside every onTransition case 
that I don't want to get executed on the initial recovery from snapshots.

I pushed my experiments here 
<https://github.com/tabdulradi/akka-persistence-fsm/blob/master/src/main/scala/sample/persistence/ViewExample.scala>
 
if any one is intersted

On Monday, March 2, 2015 at 12:01:06 PM UTC, Tamer Abdul-Radi wrote:
>
> I have this use case:
>
> class MyPersistentViewFSM extends PersistentView with LoggingFSM[State, 
> Data] {
>
>   startWith(A, ???)
>   when (A) {
>     case Event(SnapshotOffer(_, _), _) => 
>        val restoredState = ??? // Let's say we somehow figured out the 
> last state was C
>        val restoredData = ???
>        goto(restoredState) with restoredData
>     case Event(_, _) =>
>        goto(B)
>   }
>   when (B) {
>     case Event(_, _) =>
>       goto(C)
>   }
>   when (C) {
>     case _ =>
>       saveSnapshot(???)
>   }
> }
>
>
> This will trigger a state transition from `A -> C`, which is logically 
> wrong because we have to pass through B first.
> So I am thinking if there is a way to silently set the state to be C, 
> without triggering onTransition would solve the case.
>

-- 
>>>>>>>>>>      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