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