A journal and snapshot store plugin for akka-persistence using Android's built in SQLite database.
This library is tested against akka-persistence-tck.
You should add the following dependency.
libraryDependencies += "me.leaf" %% "akka-persistence-android" % "0.4"
The journal and snapshot plugins are configured as normal. There are two additional configuration items that need to be
set name
and context-lookup.class
.
name
is the name of the SQLite DB on the Android filesystem.
context-lookup.class
is an implementation of the ContextLookup
trait. A simple implementation (used by the unit tests) is included in SimpleContextLookup.
Example application.conf
:
akka {
persistence {
journal.plugin = "akka-persistence-android.journal"
snapshot-store.plugin = "akka-persistence-android.snapshot"
}
}
akka-persistence-android {
journal.class = "akka.persistence.android.journal.AndroidJournal"
snapshot.class = "akka.persistence.android.snapshot.AndroidSnapshot"
context-lookup.class = "akka.persistence.android.common.SimpleContextLookup"
name = "my-db-name"
}
The table schema is created automatically by DbHelper using Android's SQLiteOpenHelper.
Testing is enable via the RoboTest Scala wrapper for Robolectric.
Robolectric requires the Google APIs for Android (specifically the maps JAR) and and the Android support-v4 library to be in your local Maven repository.
To install these, first download them via the Android SDK tools, and then run the following:
mvn install:install-file -DgroupId=com.google.android.maps \
-DartifactId=maps \
-Dversion=18_r3 \
-Dpackaging=jar \
-Dfile="$ANDROID_HOME/add-ons/addon-google_apis-google-18/libs/maps.jar"
mvn install:install-file -DgroupId=com.android.support \
-DartifactId=support-v4 \
-Dversion=19.0.1 \
-Dpackaging=jar \
-Dfile="$ANDROID_HOME/extras/android/support/v4/android-support-v4.jar"
- The first release
- Add ContextLookup to get the context from the Android world into the Akka world
This project is descended from okumin's akka-persistence-sql-async project.