Hi Patrik, Martin,

I gave this a crack - (just had time to sit down tonight to code up some 
bits). 
But what I have found is that the EventSourcedProcessor has set receive as 
final so It doesn't look as simple.

trait EventsourcedProcessor extends Processor with Eventsourced {
  final def receive = initialBehavior
}

[error] 
/Users/rbuckland/projects/io.straight/io-straight-fw/src/main/scala/io/straight/fw/service/AbstractProcessor.scala:53:
 
overriding method receive in trait EventsourcedProcessor of type => 
AbstractProcessor.this.Receive;
[error]  method receive cannot override final member
[error]   override def receive = initializing.orElse(active)
[error]                ^


trait AbstractProcessor[T <: BaseDomain[I], E <: BaseEvent, C <: 
BaseCommand, I <: Any] extends EventsourcedProcessor {

    self ! "ResetPrimaryKeyId"

...

  override def receive = initializing.orElse(active)

  def initializing: Receive = {
    case "ResetPrimaryKeyId" =>

      // recovery has finished .. so set the ID on the repo
      idGenerator.setStartingId(repository.maxId)

      unstashAll()
      context.become(active)
    case other if recoveryFinished =>
      stash()
  }

  def active: Receive = super.receive

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]<javascript:>
> > 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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