[akka-user] Illegal to close over saveSnapshot within persistAll

2016-05-05 Thread Magnus Andersson
Hi I have a hunch this might be illegal, want to double check I have a persistent actor that receives events, buffers them and stores them with an persistAll. I also want to save a snapshot of the state now and then but that is only allowed to happen when the buffer of events have been fully f

Re: [akka-user] Illegal to close over saveSnapshot within persistAll

2016-05-05 Thread Patrik Nordwall
That should be fine. The persist and persistAll callbacks are called in the actor's ordinary receive thread. Note that the callback is invoked once per event for persistAll. It's important that the object (state in your case) you save as snapshot is immutable. /Patrik fre 6 maj 2016 kl. 00:36 sk

Re: [akka-user] Illegal to close over saveSnapshot within persistAll

2016-05-06 Thread Magnus Andersson
Hi Yes, the buffer.isEmpty and checkSnapshotTreshold will guarantee the snapshot at most called once per persistAll, when buffer is empty. I also modified it so that trySnapshot would take the State as an argument from the calling persist all. Not sure if that was necessary but it seems to be

Re: [akka-user] Illegal to close over saveSnapshot within persistAll

2016-05-06 Thread Konrad Malawski
BTW: If you want to store the snapshot after the persistAll has called all its callbacks you could instead do defer { saveSnapshot }. --  Konrad `ktoso` Malawski Akka @ Lightbend On 6 May 2016 at 10:41:02, Magnus Andersson (mag...@magnusart.com) wrote: Hi Yes, the buffer.isEmpty and checkSnaps

Re: [akka-user] Illegal to close over saveSnapshot within persistAll

2016-05-06 Thread Magnus Andersson
Aha! Thanks I'll look at that. /Magnus fre 6 maj 2016 kl 10:43 skrev Konrad Malawski : > BTW: If you want to store the snapshot after the persistAll has called all > its callbacks you could instead do defer { saveSnapshot }. > > -- > Konrad `ktoso` Malawski > Akka @ Lightbend