Overview

The Akka Persistence JDBC plugin allows for using JDBC-compliant databases as backend for Akka Persistence and Akka Persistence Query.

akka-persistence-jdbc writes journal and snapshot entries to a configured JDBC store. It implements the full akka-persistence-query API and is therefore very useful for implementing DDD-style application models using Akka and Scala for creating reactive applications.

Akka Persistence JDBC requires Akka 2.10.0 or later. It uses Slick 3.5.2 internally to access the database via JDBC, this does not require user code to make use of Slick.

Version history

Description Version Akka version
Required database schema migration, see Migration 5.4.0 Akka 2.6.+
New database schema, see Migration 5.0.0 Akka 2.6.+
First release within the Akka organization 4.0.0 Akka 2.6.+
Requires Akka 2.5.0 3.5.3+ Akka 2.5.23+ or 2.6.x

See the full release history at GitHub releases.

Module info

The Akka dependencies are available from Akka’s library repository. To access them there, you need to configure the URL for this repository.

sbt
resolvers += "Akka library repository".at("https://repo.akka.io/maven")
Maven
<project>
  ...
  <repositories>
    <repository>
      <id>akka-repository</id>
      <name>Akka library repository</name>
      <url>https://repo.akka.io/maven</url>
    </repository>
  </repositories>
</project>
Gradle
repositories {
    mavenCentral()
    maven {
        url "https://repo.akka.io/maven"
    }
}

Additionally, add the dependencies as below.

sbt
val AkkaVersion = "2.10.0"
val SlickVersion = "3.5.2"
libraryDependencies ++= Seq(
  "com.lightbend.akka" %% "akka-persistence-jdbc" % "5.5.0",
  "com.typesafe.akka" %% "akka-persistence-query" % AkkaVersion,
  "com.typesafe.slick" %% "slick" % SlickVersion,
  "com.typesafe.slick" %% "slick-hikaricp" % SlickVersion
)
Maven
<properties>
  <akka.version>2.10.0</akka.version>
  <slick.version>3.5.2</slick.version>
  <scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
  <dependency>
    <groupId>com.lightbend.akka</groupId>
    <artifactId>akka-persistence-jdbc_${scala.binary.version}</artifactId>
    <version>5.5.0</version>
  </dependency>
  <dependency>
    <groupId>com.typesafe.akka</groupId>
    <artifactId>akka-persistence-query_${scala.binary.version}</artifactId>
    <version>${akka.version}</version>
  </dependency>
  <dependency>
    <groupId>com.typesafe.slick</groupId>
    <artifactId>slick_${scala.binary.version}</artifactId>
    <version>${slick.version}</version>
  </dependency>
  <dependency>
    <groupId>com.typesafe.slick</groupId>
    <artifactId>slick-hikaricp_${scala.binary.version}</artifactId>
    <version>${slick.version}</version>
  </dependency>
</dependencies>
Gradle
def versions = [
  AkkaVersion: "2.10.0",
  SlickVersion: "3.5.2",
  ScalaBinary: "2.13"
]
dependencies {
  implementation "com.lightbend.akka:akka-persistence-jdbc_${versions.ScalaBinary}:5.5.0"
  implementation "com.typesafe.akka:akka-persistence-query_${versions.ScalaBinary}:${versions.AkkaVersion}"
  implementation "com.typesafe.slick:slick_${versions.ScalaBinary}:${versions.SlickVersion}"
  implementation "com.typesafe.slick:slick-hikaricp_${versions.ScalaBinary}:${versions.SlickVersion}"
}
Project Info: Akka Persistence JDBC
Artifact
com.lightbend.akka
akka-persistence-jdbc
5.5.0
JDK versions
Eclipse Temurin JDK 11
Eclipse Temurin JDK 17
Eclipse Temurin JDK 21
Scala versions2.13.15, 3.3.4
JPMS module nameakka.persistence.jdbc
License
Readiness level
Supported, support is available from Lightbend
Since 5.1.0, 2022-10-05
Home pagehttps://doc.akka.io/libraries/akka-persistence-jdbc/current/
Forums
Release notesGitHub releases
IssuesGitHub issues
Sourceshttps://github.com/akka/akka-persistence-jdbc

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project’s open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project’s open source license and warrant that you have the legal authority to do so.

Code of Conduct

Contributors all agree to follow the Lightbend Community Code of Conduct.

License

This source code is made available under the Business Source License 1.1

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.