3

My application needs to log all messages processed by an actor and replay messages between minSequenceNr and maxSequenceNr sometimes.

Is akka-persistence a good for this use case? If yes, How can I force replay messages from journal? I can use Persistence(actorSystem).journalFor("x") to get a journal's ActorRef but I can't send JournalProtocol.ReplayMessages to it because JournalProtocol is private for akka.persistence.

Andrey Kuznetsov
  • 11,640
  • 9
  • 47
  • 70

1 Answers1

4

This question was asked and answered on akka-user already: https://groups.google.com/forum/#!topic/akka-user/AJjdIt_bztM

On Akka 2.3.x (very old version)

Have you read the docs about recovery http://doc.akka.io/docs/akka/2.3.4/scala/persistence.html#recovery ? You can start recovery by sending an Recover(toSequenceNr: Long) message to yourself.

We do not support ranged (as in “from 200 to 400”) playback, skipping events (the “from N”) does not match eventsourcing philosophy very well.

On the other hand, you can easily issue an replay “to 400”, and simply in your actor choose to ignore any event with seqNr lower than 200, which achieves the same end result you’re after.

On Akka 2.4.x

Akka Persistence since entering the stable release in 2.4 disallows randomly replaying in the middle of your lifetime. We found it caused more bugs than benefit to people. Please read http://doc.akka.io/docs/akka/2.4.5/scala/persistence.html

I hope this helps, happy hakking!

Konrad 'ktoso' Malawski
  • 13,102
  • 3
  • 47
  • 52
  • This does not seem to be valid anynmore? – ixaxaar May 17 '16 at 09:12
  • Correct, it's outdated since the arrival of Akka 2.4 – which disallows randomly replaying in the middle of your lifetime. We found it caused more bugs than benefit to people. Please read http://doc.akka.io/docs/akka/2.4.5/scala/persistence.html – Konrad 'ktoso' Malawski May 18 '16 at 09:15