This example uses
- Akka Persistence for persistent actors,
- Persistent FSM (finite state machine) for states and transitions,
- akka-persistence-sql-async as storage plugin to connect to a PostgreSQL database.
- 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
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.