Hi,

Thanks for your response. Let me (try to) clarify my questions.

I guess I oversimplified my example so it, so I'll try again. I have an 
actor (persistent with at-least-once-delivery), and I want it to process 
messages "immediately" upon arrival. That is, I don't want to wait for the 
persistence handlers to fire before updating my state, delivering messages 
downstream, etc.. I would also like to be able to recover from crashes to a 
consistent state.

So now let's look at an example actor (assuming recovery behaves exactly 
the same, but without the persistence calls):

class MyActor extends PersistentActor with AtLeastOnceDelivery {
  var counter = 0
  override def receiveCommand: Receive = {
    case Increment =>
      counter += 1
      deliver(somewhere, id => Count(counter, id))
      persistAsync(Increment) { _ =>
        sender ! Persisted
      }
    case a@Ack(id) =>
      counter -= 1
      confirmDelivery(id)
      persistAsync(a) { _ =>
        // nothing to do here
      }
    case Snapshot =>
      saveSnapshot(Snapshot(counter, getDeliverySnapshot))
  }
}


Here, I would expect the counter to be the same as the number of 
unconfirmed messages as long as there are no crashes.

Could I miss messages here? Would crashes always restore my actor to a 
consistent state as well?

I didn't observe any problems, it was just something I thought about during 
the design phase, and since it relates to thread timings and crashes it 
would be kind of hard to create the problematic scenarios ahead-of-time.

Thanks,
Tal


On Monday, March 9, 2015 at 3:55:39 PM UTC+2, Patrik Nordwall wrote:
>
> I don't see what this has to do with snapshots, and what the problem could 
> be. This is not the kind of mutability that Björn warned about. He was 
> thinking about mutability of the instance passed to saveSnapshot.
>
 

>  You can do that, but then you risk that the message may not be delivered 
> (re-delivered) if things crash before the event has been saved.
>
> Snapshots and persistent events are not re-ordered, so it is supposed to 
> just work, and that should not change because of persistAsync. Have you 
> seen any problems?
>

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