On Thu, Mar 13, 2014 at 9:10 AM, Ramon Buckland <[email protected]>wrote:
> Thanks Martin, and Patrik, that makes complete sense.
> given another few hours and thinking time I was almost there ;-)
>
> I realised it had to be message based and instantly my fear was ("what if
> another message gets in there before mine :-)!!") and Patrik you answered
> it!
>
> Many thanks.
>
You're welcome. Good question. We should document it:
https://www.assembla.com/spaces/akka/tickets/3924
/Patrik
>
> On Thursday, 13 March 2014 08:01:53 UTC, Patrik Nordwall wrote:
>>
>>
>>
>>
>> On Thu, Mar 13, 2014 at 8:19 AM, Martin Krasser
>> <[email protected]>wrote:
>>
>>> Hi Ramon,
>>>
>>> in eventsourced, the application was responsible for delaying new
>>> messages to a processor until recovery completes (otherwise new messages
>>> could wrongy interleave with replayed messages). This is not necessary
>>> anymore with akka-persistence. New messages are internally buffered until
>>> recovery completes (see also migration
>>> guide<http://doc.akka.io/docs/akka/2.3.0/project/migration-guide-eventsourced-2.3.x.html>
>>> ).
>>>
>>> Akka-persistence doesn't notify applications with a separate message
>>> when recovery completed but you can easily achieve that by sending a
>>> processor a non-Persistent message immediately after creation. The
>>> processor will then receive this as first message immediately after
>>> recovery completed which is equivalent to a recovery-completed
>>> notification. You could even send that message from an overridden preStart
>>> or preRestart.
>>>
>>
>> I would like to add that the mailbox may contain messages that are queued
>> in front of that message. That can happen both during restarts, and if you
>> send another message to the ActorRef from the outside immediately after
>> creation. Therefore you need to stash until you receive that FIRST message.
>>
>> Something like this:
>>
>> class MyProcessor extends Processor {
>> self ! "FIRST"
>>
>> def receive = initializing.orElse(active)
>>
>> def initializing: Receive = {
>> case "FIRST" =>
>> unstashAll()
>> context.become(active)
>> case other if recoveryFinished =>
>> stash()
>> }
>>
>> def active: Receive = {
>> case Persistent(msg, _) => //...
>> }
>> }
>>
>> /Patrik
>>
>>
>>
>>>
>>> Cheers,
>>> Martin
>>>
>>>
>>> On 12.03.14 21:38, Ramon Buckland wrote:
>>>
>>> Hi All,
>>>
>>> I am currently converting my framework over to akka-persistence from
>>> eventsourced.
>>>
>>> I want to be notified when the recovery is complete, and do some work
>>> before accepting new messages.
>>>
>>> How would I know that recovery is complete ?
>>>
>>> Would I need to overide preRestart and somehow poll self for the
>>> existence of recoveryFinished ?
>>>
>>> Specifically what I need to do is reset counter so that new keys,
>>> begin where they last left off.
>>> I have another method which I may use but was hoping for a hook I could
>>> reuse.
>>>
>>> thanks
>>> --
>>> >>>>>>>>>> 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.
>>>
>>>
>>> --
>>> Martin Krasser
>>>
>>> blog: http://krasserm.blogspot.com
>>> code: http://github.com/krasserm
>>> twitter: http://twitter.com/mrt1nz
>>>
>>> --
>>> >>>>>>>>>> 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.
>
--
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.