Hi Andrew,

There is the defer method which handles this case rather nicely. 

case Message =>
  val events = ...
  persist(events)
  defer() { _ => sender() ! Ack } // Not run until persist completes

On Friday, July 17, 2015 at 10:47:01 AM UTC-4, Andrew Easter wrote:
>
> I've got a persistent actor that, on processing a command, generates 
> multiple events. There is support for persisting multiple events in the API:
>
> def persist[A](events: immutable.Seq[A])(handler: A => Unit): Unit
>
> In my use case, after all the events have been persisted, I wish to send 
> an command acknowledgement to the sender:
>
> sender() ! Ack
>
> However, because the event handler is invoked per event, I can't easily 
> achieve invoking the sender acknowledgement only once all events have been 
> handled.
>
> Am I missing something obvious that would help serve my use 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 [email protected].
To post to this group, send email to [email protected].
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