JannikArndt / akka-persistence-postgresql-example

Example for using Akka Persistent FSM with PostgreSQL as storage plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Akka Persistence with PostgreSQL Journal & Snapshot Example

This example uses

Getting started

  • fire up a PostgreSQL database
  • run the Create Journal and Snapshot.sql script to create the tables
  • make sure the configuration in src/main/resources/application.conf match your database
  • sbt test

Running in the console

sbt> console
scala> import akka.actor.{ActorRef, ActorSystem, Props}
scala> import ranked._
scala> val system = ActorSystem("TestSystem")
scala> val game: ActorRef = system.actorOf(Props[Game], "game1")

scala> game ! StartGame
scala> game ! NewGoal(TeamA)
scala> game ! NewGoal(TeamB)

scala> system.terminate()
scala> :quit
sbt> console

scala> import akka.actor.{ActorRef, ActorSystem, Props}
scala> import ranked._
scala> val system = ActorSystem("TestSystem")
scala> val game: ActorRef = system.actorOf(Props[Game], "game1")
[INFO] Recovery completed!

scala> scala> game ! PrintScore()
[INFO] Score: Team A has 2 goals and Team B has 2 goals.

About

Example for using Akka Persistent FSM with PostgreSQL as storage plugin


Languages

Language:Scala 100.0%