Skip to content

Commit 1c57ba7

Browse files
committed
Add README
1 parent 41a9051 commit 1c57ba7

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# akka-persistence-sql-async
2+
3+
A journal and snapshot store plugin for [akka-persistence](http://doc.akka.io/docs/akka/2.3.6/scala/persistence.html) using RDBMS.
4+
Akka-persistence-sql-async executes queries by [ScalikeJDBC-Async](https://github.com/scalikejdbc/scalikejdbc-async) that provides non-blocking APIs to talk to databases.
5+
6+
7+
Akka-persistence-sql-async supports following databases.
8+
- MySQL
9+
- PostgreSQL
10+
11+
## Usage
12+
13+
In application.conf,
14+
15+
```
16+
akka {
17+
persistence {
18+
journal.plugin = "akka-persistence-sql-async.journal"
19+
snapshot-store.plugin = "akka-persistence-sql-async.snapshot-store"
20+
21+
# disable leveldb (default store impl)
22+
journal.leveldb.native = off
23+
}
24+
}
25+
26+
akka-persistence-sql-async {
27+
journal.class = "akka.persistence.journal.sqlasync.MySQLAsyncWriteJournal"
28+
snapshot-store.class = "akka.persistence.snapshot.sqlasync.MySQLSnapshotStore"
29+
30+
# For PostgreSQL
31+
# journal.class = "akka.persistence.journal.sqlasync.PostgreSQLAsyncWriteJournal"
32+
# snapshot-store.class = "akka.persistence.snapshot.sqlasync.PostgreSQLSnapshotStore"
33+
34+
user = "root"
35+
pass = ""
36+
url = "jdbc:mysql://localhost/akka_persistence_sql_async"
37+
max-pool-size = 4
38+
journal-table-name = "journal"
39+
snapshot-table-name = "snapshot"
40+
}
41+
```
42+
43+
## Table schema
44+
45+
Create the database and tables for journal and snapshot store.
46+
47+
### MySQL
48+
49+
```
50+
CREATE TABLE IF NOT EXISTS {your_journal_table_name} (
51+
persistence_id VARCHAR(255) NOT NULL,
52+
sequence_nr BIGINT NOT NULL,
53+
marker VARCHAR(255) NOT NULL,
54+
message BLOB NOT NULL,
55+
created_at TIMESTAMP NOT NULL,
56+
PRIMARY KEY (persistence_id, sequence_nr)
57+
);
58+
59+
CREATE TABLE IF NOT EXISTS {your_snapshot_table_name} (
60+
persistence_id VARCHAR(255) NOT NULL,
61+
sequence_nr BIGINT NOT NULL,
62+
created_at BIGINT NOT NULL,
63+
snapshot BLOB NOT NULL,
64+
PRIMARY KEY (persistence_id, sequence_nr)
65+
);
66+
```
67+
68+
### PostgreSQL
69+
70+
```
71+
CREATE TABLE IF NOT EXISTS {your_journal_table_name} (
72+
persistence_id VARCHAR(255) NOT NULL,
73+
sequence_nr BIGINT NOT NULL,
74+
marker VARCHAR(255) NOT NULL,
75+
message BYTEA NOT NULL,
76+
created_at TIMESTAMP NOT NULL,
77+
PRIMARY KEY (persistence_id, sequence_nr)
78+
);
79+
80+
81+
CREATE TABLE IF NOT EXISTS {your_snapshot_table_name} (
82+
persistence_id VARCHAR(255) NOT NULL,
83+
sequence_nr BIGINT NOT NULL,
84+
created_at BIGINT NOT NULL,
85+
snapshot BYTEA NOT NULL,
86+
PRIMARY KEY (persistence_id, sequence_nr)
87+
);
88+
```
89+
90+
## License
91+
92+
Apache 2.0

0 commit comments

Comments
 (0)