Skip to content

A simple example that demonstrates the usage of Akka Persistence along with Protocol Buffers as the serialization mechanism

Notifications You must be signed in to change notification settings

calvinlfer/Akka-Persistence-example-with-Protocol-Buffers-serialization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Akka Persistence example with Protocol Buffers serialization

Build Status

Build Status

Overview

This example uses ScalaPB in order to obtain case class support for Scala when generating code from *.proto files. ScalaPB uses the protoc-jar internally to compile your protocol buffer files.

Execute sbt run in order to run the Main application. The Calculator actor is used to persist events across runs using Event Sourcing. We define a custom serializer that makes use of the generated class' (from proto) serialization mechanisms to easily serialize and deserialize events.

The Main application fires events at the Calculator actor. Since Calculator actor is Persistent, it makes use of the Serializer (set up in application.conf) when reading and persistent events to/from the event journal.

We also have a test that exercises the Persistent Calculator Actor by sending it events, killing it and making sure it uses Event Sourcing to bring the Calculator up to the current state. You can use sbt test to run the test.

If you are using IntelliJ and want syntax highlighting, then make sure your directory setup looks like this: image

External Libraries

  • ScalaPB is used to generate Scala case classes from proto files. These case classes have the ability to convert to and from binary
  • Akka for its actor framework, persistence module and test kit

Warning: Make sure you have Python 2.7 installed (accessible via python) otherwise the protocol buffers compiler will give you errors and will not compile your project

About

A simple example that demonstrates the usage of Akka Persistence along with Protocol Buffers as the serialization mechanism

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published