Akka Persistence Redis Plugin
- What is it?
- Using the Journal Component
- Using the Snapshot Component
- Using the Journal Query Interface Component
- Database Configuration
What is it?
Akka Persistence Redis Plugin is a plugin for Akka persistence that provides several components:
- a journal store ;
- a snapshot store ;
- a journal query interface implementation.
This plugin stores data in a redis database.
The plugin is compiled with Scala 2.13, 2.12 and 2.11 and deployed on the maven sonatype repositories. To use the plugin add this to your sbt build file :
libraryDependencies += "com.safety-data" %% "akka-persistence-redis" % "0.4.2"
Note: for snapshot versions you will need to add the sonatype snapshot resolver.
The journal and snapshot components save serialized values into the database. They rely on the Akka serialization extension. Custom serialization can be added to handle you data model elements as you wish.
Using the Journal Component
To use the journal component, you need to enable it in your configuration. To use the default settings, simply add this line:
akka.persistence.journal.plugin = "akka-persistence-redis.journal"
The journal component has support for tagged events. All events wrapped inside an instance of class
akka.persistence.journal.Tagged are associated to the provided tags in the data store.
Using the Snapshot Component
To use the snapshot component, you need to enable it in your configuration. To use the default settings, simply add this line:
akka.persistence.snapshot.plugin = "akka-persistence-redis.snapshot"
Using the Journal Query Interface Component
To use the journal query component, you need to enable it in your configuration. To use the default settings, simply add this line:
import akka.persistence.query._ import akka.persistence.query.journal.redis._ val readJournal = PersistenceQuery(system) .readJournalFor[ScalaReadJournal]("akka-persistence-redis.read-journal")
For more details on the available capabilities of the journal query, please refer to the API documentation.
Akka persistence redis plugin supports following modes for connecting to Redis:
A default database configuration is used for all components, under the path
akka-persistence-redis.redis. You may either override this path to apply changes to all components, or override it locally for each component.
See the reference configuration for more details on possible configuration.
This work is inspired by Akka Persistence Redis Plugin by HootSuite Media Inc licensed under Apache license version 2.
Copyright © 2017 Safety Data - CFH SAS.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.