On Fri, Mar 20, 2015 at 8:41 PM, neeraj agarwal <
[email protected]> wrote:

> Then what is the point? Do I always create an actor that does the
> persistence and then passes on the message to its child?
> Otherwise, the messages that are in mailbox will be lost?
>

You must explicitly persist the events. The events may be the same as the
incoming messages, know as command sourcing, but typically they represent
incremental changes of the state of the actor, know as event sourcing.

You can't know that something has been successfully persisted until the
callback handler of the persist method is invoked. There is where you can
send an acknowledgment to the sender that the request has been taken care
of. Before that point messages may be lost on the way to the actor, in the
mailbox, on the way to the journal, and so on.

Regards,
Patrik


>
>
> On Friday, March 20, 2015 at 7:46:01 PM UTC+5:30, neeraj agarwal wrote:
>>
>> I am looking at a akka sample, a code snippet:
>>
>> persist(asList(evt1, evt2), new Procedure<Evt>() {
>>                 public void apply(Evt evt) throws Exception {
>>                     state.update(evt);
>>                     if (evt.equals(evt2)) {
>>                         getContext().system().eventStream().publish(evt);
>>                     }
>>                 }
>>             });
>>
>> Is it that we need to persist messages first and then move on, and AFTER
>> we explicitly persist it, if actor gets killed, or the system gets killed,
>> then only we would be getting messages in recovery?
>>
>> Is it not that the messages are persisted by default, and after that they
>> are sent to onReceiveCommand? And in case system crashes during this, then
>> the next time the same system comes up, onReceiveRecover gets called with
>> the persisted messages first, and then onReceiveCommand with the current
>> messages?
>>
>> On Friday, March 20, 2015 at 7:33:43 PM UTC+5:30, Anders Båtstrand wrote:
>>>
>>> Hi
>>>
>>> You need to persist messages, see UntypedPersistentActor#persist.
>>>
>>> RecoveryCompleted is always received upon startup, yes. Even if the
>>> journal did not contain any messages.
>>>
>>> Best regards,
>>>
>>> Anders Båtstrand
>>>
>>  --
> >>>>>>>>>> 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.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

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