akka-persistence-mapdb is a plugin for akka-persistence which uses MapDB for storing journal and snapshot messages.
Add the following dependency to your build.sbt
:
libraryDependencies += "com.fgrutsch" %% "akka-persistence-mapdb" % "<latest>"
Add the following to your application.conf
to use akka-persistence-mapdb as the persistence backend:
akka {
persistence {
journal {
plugin = "mapdb-journal"
}
snapshot-store {
plugin = "mapdb-snapshot"
}
}
}
This is the minimum required configuration you need to use akka-persistence-mapdb
. No further configuration is needed to get it running. Be aware that this by default stores data in memory, check out the full documentation on how to change that.
If you need to query the stored events you can use Persistence Query to stream them from the journal. All queries are supported:
import akka.actor.ActorSystem
import akka.persistence.query.PersistenceQuery
import com.fgrutsch.akka.persistence.mapdb.query.scaladsl.MapDbReadJournal
val actorSystem: ActorSystem = ???
val readJournal: MapDbReadJournal = PersistenceQuery(actorSystem).readJournalFor[MapDbReadJournal](MapDbReadJournal.Identifier)
For the full documentation please check this link.
The code of this project is heavily inspired and based on the akka-persistence-jdbc backend implementation. Go check it out!
This code is licensed under the Apache 2.0 License.