Search code examples
scalaakka-persistence

Clearing Messages From a persistent Akka journal


I am testing a persistent Akka actor. I am using in-memory persistence for this. The test starts and I see the actor recovering persisted messages. I try the following:

I send a message to the actor that makes it trigger deleteMessages(LastMessage). I was hoping this message would cause the journal to be cleared. The actor does not seem to process this message as the messages being recovered had previously run into an exception. It thus throws the exception and does not proceed to process the message.

How can I clear the persisted the journal?

I also thought the in memory persistence does not recover previous tests messages from the journal


Solution

  • For a more capable in-memory journal implementation to use in tests, I'd recommend using https://github.com/dnvriend/akka-persistence-inmemory.

    It supports clearing the journal (and snapshots): https://github.com/dnvriend/akka-persistence-inmemory#clearing-journal-and-snapshot-messages, as well as ReadJournal.