Skip to content

Commit

Permalink
Document for 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
okumin committed Oct 6, 2015
1 parent 3196800 commit 58bbece
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

[![Build Status](https://travis-ci.org/okumin/akka-persistence-sql-async.svg?branch=master)](https://travis-ci.org/okumin/akka-persistence-sql-async)

A journal and snapshot store plugin for [akka-persistence](http://doc.akka.io/docs/akka/2.3.11/scala/persistence.html) using RDBMS.
A journal and snapshot store plugin for [akka-persistence](http://doc.akka.io/docs/akka/2.4.0/scala/persistence.html) using RDBMS.
Akka-persistence-sql-async executes queries by [ScalikeJDBC-Async](https://github.com/scalikejdbc/scalikejdbc-async) that provides non-blocking APIs to talk to databases.


Akka-persistence-sql-async supports following databases.
- MySQL
- PostgreSQL

This library is tested against [akka-persistence-tck](http://doc.akka.io/docs/akka/2.3.11/scala/persistence.html#plugin-tck).
This library is tested against [akka-persistence-tck](http://doc.akka.io/docs/akka/2.4.0/scala/persistence.html#plugin-tck).

## Usage

Expand All @@ -19,7 +19,7 @@ This library is tested against [akka-persistence-tck](http://doc.akka.io/docs/ak
You should add the following dependency.

```
libraryDependencies += "com.okumin" %% "akka-persistence-sql-async" % "0.2.1"
libraryDependencies += "com.okumin" %% "akka-persistence-sql-async" % "0.3.0"
```

And then, please include the mysql-async if you use MySQL.
Expand Down Expand Up @@ -49,18 +49,20 @@ akka {
akka-persistence-sql-async {
journal.class = "akka.persistence.journal.sqlasync.MySQLAsyncWriteJournal"
snapshot-store.class = "akka.persistence.snapshot.sqlasync.MySQLSnapshotStore"
# For PostgreSQL
# journal.class = "akka.persistence.journal.sqlasync.PostgreSQLAsyncWriteJournal"
# snapshot-store.class = "akka.persistence.snapshot.sqlasync.PostgreSQLSnapshotStore"
user = "root"
password = ""
url = "jdbc:mysql://localhost/akka_persistence_sql_async"
max-pool-size = 4 # total connection count
wait-queue-capacity = 10000 # If query cannot be executed soon, it wait in the queue and will be executed later.
journal-table-name = "journal"
snapshot-table-name = "snapshot"
max-pool-size = 4
wait-queue-capacity = 10000
metadata-table-name = "persistence_metadata"
journal-table-name = "persistence_journal"
snapshot-table-name = "persistence_snapshot"
}
```

Expand All @@ -71,48 +73,64 @@ Create the database and tables for journal and snapshot store.
### MySQL

```
CREATE TABLE IF NOT EXISTS {your_journal_table_name} (
CREATE TABLE IF NOT EXISTS {your_metadata_table_name} (
persistence_key BIGINT NOT NULL AUTO_INCREMENT,
persistence_id VARCHAR(255) NOT NULL,
sequence_nr BIGINT NOT NULL,
marker VARCHAR(255) NOT NULL,
PRIMARY KEY (persistence_key),
UNIQUE (persistence_id)
) ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS {your_journal_table_name} (
persistence_key BIGINT NOT NULL,
sequence_nr BIGINT NOT NULL,
message BLOB NOT NULL,
created_at TIMESTAMP NOT NULL,
PRIMARY KEY (persistence_id, sequence_nr)
);
PRIMARY KEY (persistence_key, sequence_nr),
FOREIGN KEY (persistence_key) REFERENCES {your_metadata_table_name} (persistence_key)
) ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS {your_snapshot_table_name} (
persistence_id VARCHAR(255) NOT NULL,
persistence_key BIGINT NOT NULL,
sequence_nr BIGINT NOT NULL,
created_at BIGINT NOT NULL,
snapshot BLOB NOT NULL,
PRIMARY KEY (persistence_id, sequence_nr)
);
PRIMARY KEY (persistence_key, sequence_nr),
FOREIGN KEY (persistence_key) REFERENCES {your_metadata_table_name} (persistence_key)
) ENGINE = InnoDB;
```

### PostgreSQL

```
CREATE TABLE IF NOT EXISTS {your_journal_table_name} (
CREATE TABLE IF NOT EXISTS {your_metadata_table_name} (
persistence_key BIGSERIAL NOT NULL,
persistence_id VARCHAR(255) NOT NULL,
sequence_nr BIGINT NOT NULL,
marker VARCHAR(255) NOT NULL,
message BYTEA NOT NULL,
created_at TIMESTAMP NOT NULL,
PRIMARY KEY (persistence_id, sequence_nr)
PRIMARY KEY (persistence_key),
UNIQUE (persistence_id)
);
CREATE TABLE IF NOT EXISTS {your_journal_table_name} (
persistence_key BIGINT NOT NULL REFERENCES {your_metadata_table_name}(persistence_key),
sequence_nr BIGINT NOT NULL,
message BYTEA NOT NULL,
PRIMARY KEY (persistence_key, sequence_nr)
);
CREATE TABLE IF NOT EXISTS {your_snapshot_table_name} (
persistence_id VARCHAR(255) NOT NULL,
persistence_key BIGINT NOT NULL REFERENCES {your_metadata_table_name}(persistence_key),
sequence_nr BIGINT NOT NULL,
created_at BIGINT NOT NULL,
snapshot BYTEA NOT NULL,
PRIMARY KEY (persistence_id, sequence_nr)
PRIMARY KEY (persistence_key, sequence_nr)
);
```

## Release Notes

### 0.2.1 - Sep 25, 2015
- [Keep the highest sequence number](https://github.com/okumin/akka-persistence-sql-async/issues/6)

### 0.2 - Apr 5, 2015
- [Change pass to password in configuration](https://github.com/okumin/akka-persistence-sql-async/issues/3)

Expand Down

0 comments on commit 58bbece

Please sign in to comment.