GithubHelp home page GithubHelp logo

kelnos / akka-persistence-jdbc Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 9 KB

A JDBC plugin for the akka-persistence framework (http://doc.akka.io/docs/akka/current/scala/persistence.html)

License: BSD 3-Clause "New" or "Revised" License

Scala 100.00%

akka-persistence-jdbc's Introduction

akka-persistence-jdbc

WARNING: This is a brand-new library that has not undergone any performance, longevity, memory-leak, or robustness testing. Use it at your own risk.

This is an akka-persistence plugin that uses JDBC to persist actor state to a database.

This plugin passes the akka-persistence-tck test suite.

Features

  • Minimal dependencies (uses JDBC directly).
  • Uses the HikariCP connection pool.
  • Makes use of standard battle-tested JVM JDBC drivers.
  • Cross-compiles against Scala 2.11 and 2.12.

Database Support

  • MySQL
  • MariaDB

Building

Assuming you have sbt installed somewhere in your PATH, run

$ sbt +package

Running Tests

The tests require a live MySQL (or MariaDB) instance to be running. It does not clean up after itself, so you'll have to manually drop tables after running it (or between runs). You'll also need to create a database called akka_persist_test. The default test setup assumes a database instance running on localhost, with username root and no password. Just run:

$ sbt +test

Usage

Via Maven/SBT

This library is not yet published to a Maven repository, so you'll need to build and publish it locally (sbt +publishM2) for now, and then:

Maven

<dependency>
  <groupId>org.spurint</groupId>
  <artifactId>akka-persistence-jdbc_${SCALA_BINARY_VERSION}</artifactId>
  <version>${VERSION}</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>${VERSION}</version>
  <scope>compile</scope>
</dependency>

SBT

libraryDependencies ++= Seq(
  "org.spurint" %% "akka-persistence-jdbc" % "VERSION" % Compile,
  "mysql" % "mysql-connector-java" % "VERSION" % Compile
)

Application

Add to your app's application.conf:

akka.persistence.journal.plugin = "org.spurint.akka-persistence-jdbc.journal"
akka.persistence.snapshot-store.plugin = "org.spurint.akka-persistence-jdbc.snapshot-store"

org.spurint.akka-persistence-jdbc {
  journal {
    driver-class-name = "com.mysql.jdbc.Driver"
    jdbc-url = "jdbc:mysql://db.example.com/akka_persistence?user=akka&password=secret"
  }
  snapshot-store {
    driver-class-name = "com.mysql.jdbc.Driver"
    jdbc-url = "jdbc:mysql://db.example.com/akka_persistence?user=akka&password=secret"
  }
}

See the included reference.conf (in src/main/resources) for other tweakable properties.

Database

The plugin expects that the database you've specified already exists. It will, however, create the needed tables for you on startup if they don't exist already.

Missing Features

  • HikariCP exposes a bunch of configuration knobs that are not yet exposed.
  • Lots of testing; I would not consider this production-quality yet.
  • Support for RDBMSes other than MySQL/MariaDB.

akka-persistence-jdbc's People

Contributors

kelnos avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.