O'Reilly logo

Building Applications with Scala by Diego Pacheco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Persistence

Akka works on memory. However, it is possible to use persistence. Persistence is still kind of experimental in Akka. However, it is stable. For production, you can use advanced persistence plugins, such as Apache Cassandra. For the sake of development and education, we will use Google leveldb in our file system. Akka has multiple persistence options, such as views and persistent Actors.

Let's take a look at a persistent actor using the Google leveldb and file system:

 import akka.actor._ import akka.persistence._ import scala.concurrent.duration._ class PersistenceActor extends PersistentActor{ override def persistenceId = "sample-id-1" var state:String = "myState" var count = 0 def receiveCommand: Receive = { case payload: String => ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required