Git Product home page Git Product logo

akka-persistence-mongo's Introduction

An Akka Persistence Plugin for Mongo

Build Status

A replicated Akka Persistence journal backed by MongoDB Casbah.

Prerequisites

Release

Technology Version
Plugin 0.7.4
Scala 2.10.4, 2.11.2 - Cross Compiled
Akka 2.3.5 or higher
Mongo 2.4.8 or higher

Snapshot

Technology Version
Plugin 0.7.5-SNAPSHOT
Scala 2.10.4, 2.11.4 - Cross Compiled
Akka 2.3.7 or higher
Mongo 2.6.x or higher

Important Changes Starting with Version 0.7.5-SNAPSHOT

Due to the stability of the plugin and the increasing number of requests to publish to Maven Central Releases, we have implemented an official release strategy. In doing so, please note the following changes:

  • Starting with version 0.7.5-SNAPSHOT The organization name has changed from com.github.ddevore to com.github.ironfish.

  • Versions 0.7.5 and beyond, when released, will be tagged and published to https://oss.sonatype.org/content/repositories/releases.

  • Snapshots will continue to be published to https://oss.sonatype.org/content/repositories/snapshots and use the version moniker #.#.#-SNAPSHOT.

  • When a snapshot is migrated to release, it will be tagged, published, and will no longer be available in the snapshots repository.

  • If your looking or the Sample Applications, they have been moved to their own repo.

Just standard release management stuff. Nothing to see here move along. :-)

Installation

SBT

Release

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases"

libraryDependencies ++= Seq(
  "com.github.ddevore" %% "akka-persistence-mongo-casbah"  % "0.7.4" % "compile")

Snapshot

resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"

libraryDependencies ++= Seq(
  "com.github.ironfish" %% "akka-persistence-mongo-casbah"  % "0.7.5-SNAPSHOT" % "compile")

Maven

Release

// Scala 2.10.4
<dependency>
    <groupId>com.github.ddevore</groupId>
    <artifactId>akka-persistence-mongo-casbah_2.10</artifactId>
    <version>0.7.4</version>
</dependency>

// Scala 2.11.2
<dependency>
    <groupId>com.github.ddevore</groupId>
    <artifactId>akka-persistence-mongo-casbah_2.11</artifactId>
    <version>0.7.4</version>
</dependency>

Snapshot

// Scala 2.10.4
<dependency>
    <groupId>com.github.ironfish</groupId>
    <artifactId>akka-persistence-mongo-casbah_2.10</artifactId>
    <version>0.7.5-SNAPSHOT</version>
</dependency>

// Scala 2.11.4
<dependency>
    <groupId>com.github.ironfish</groupId>
    <artifactId>akka-persistence-mongo-casbah_2.11</artifactId>
    <version>0.7.5-SNAPSHOT</version>
</dependency>

Build Locally

You can build and install the plugin to your local Ivy cache. This requires sbt 0.13.5 or above.

sbt publishLocal


It can then be included as dependency:

libraryDependencies += "com.github.ironfish" %% "akka-persistence-mongo-casbah" % "0.7.5-SNAPSHOT"

Mongo Specific Details

Both the Journal and Snapshot configurations use the following Mongo components for connection management and write guarantees.

Mongo Connection String URI

The Mongo Connection String URI Format is used for establishing a connection to Mongo. Please note that while some of the components of the connection string are [optional] from a Mongo perspective, they are [required] for the Journal and Snapshot to function properly. Below are the required and optional components.

Standard URI connection scheme

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][.collection][?options]]

Required

Component Description
mongodb:// The prefix to identify that this is a string in the standard connection format.
host1 A server address to connect to. It is either a hostname, IP address, or UNIX domain socket.
/database The name of the database to use.
.collection The name of the collection to use.

Optional

Component Description
username:password@ If specified, the client will attempt to log in to the specific database using these credentials after connecting to the mongod instance.
:port1 The default value is :27017 if not specified.
hostN You can specify as many hosts as necessary. You would specify multiple hosts, for example, for connections to replica sets.
:portN The default value is :27017 if not specified.
?options Connection specific options. See Connection String Options for a full description of these options.

Mongo Write Concern

Write concern describes the guarantee that MongoDB provides when reporting on the success of a write operation. The strength of the write concerns determine the level of guarantee. The following write concerns are supported.

Write Concern Description
acknowledged [Safe] - Exceptions are raised for network issues and server errors; waits on a server for the write operation.
journaled [JournalSafe] - Exceptions are raised for network issues, and server errors; the write operation waits for the server to group commit to the journal file on disk.
replicas-acknowledged [ReplicasSafe] - Exceptions are raised for network issues and server errors; waits for at least 2 servers for the write operation.

Journal Configuration

Activation

To activate the journal feature of the plugin, add the following line to your Akka application.conf. This will run the journal with its default settings.

akka.persistence.journal.plugin = "casbah-journal"

Connection

The default mongo-journal-url is a string with a value of:

casbah-journal.mongo-journal-url = "mongodb://localhost:27017/store.messages"


This value can be changed in the application.conf with the following key:

casbah-journal.mongo-journal-url

# Example
casbah-journal.mongo-journal-url = "mongodb://localhost:27017/employee.events"


See the Mongo Connection String URI section of this document for more information.

Write Concern

The default mongo-journal-write-concern is a string with a value of:

casbah-journal.mongo-journal-write-concern = "journaled"


This value can be changed in the application.conf with the following key:

casbah-journal.mongo-journal-write-concern

# Example
casbah-journal.mongo-journal-write-concern = "replicas-acknowledged"

Write Concern Timeout

The default mongo-journal-write-concern-timeout is an int in milliseconds with a value of:

casbah-journal-mongo-journal-write-concern-timeout = 10000


This value can be changed in the application.conf with the following key:

casbah-journal-mongo-journal-write-concern-timeout

# Example
casbah-journal-mongo-journal-write-concern-timeout = 5000


See the Mongo Write Concern section of this document for more information.

Snapshot Configuration

Activation

To activate the snapshot feature of the plugin, add the following line to your Akka application.conf. This will run the snapshot-store with its default settings.

akka.persistence.snapshot-store.plugin = "casbah-snapshot-store"

Connection

The default mongo-snapshot-url is a string with a value of:

casbah-snapshot-store.mongo-snapshot-url = "mongodb://localhost:27017/store.snapshots"


This value can be changed in the application.conf with the following key:

casbah-snapshot-store.mongo-snapshot-url

# Example
casbah-snapshot-store.mongo-snapshot-url = "mongodb://localhost:27017/employee.snapshots"


See the Mongo Connection String URI section of this document for more information.

Write Concern

The default mongo-snapshot-write-concern is a string with a value of:

casbah-snapshot-store.mongo-snapshot-write-concern = "journaled"


This value can be changed in the application.conf with the following key:

casbah-snapshot-store.mongo-snapshot-write-concern

# Example
casbah-snapshot-store.mongo-snapshot-write-concern = "replicas-acknowledged"


See the Mongo Write Concern section of this document for more information.

Write Concern Timeout

The default mongo-snapshot-write-concern-timeout is an int in milliseconds with a value of:

casbah-snapshot-store.mongo-snapshot-write-concern-timeout = 10000


This value can be changed in the application.conf with the following key:

casbah-snapshot-store.mongo-snapshot-write-concern-timeout

# Example
casbah-snapshot-store.mongo-snapshot-write-concern-timeout = 5000

Snapshot Load Attempts

The snapshot feature of the plugin allows for the selection of the youngest of {n} snapshots that match an upper bound specified by configuration. This helps where a snapshot may not have persisted correctly because of a JVM crash. As a result an attempt to load the snapshot may fail but an older may succeed.

The default mongo-snapshot-load-attempt is an int with a value of:

casbah-snapshot-store.mongo-snapshot-load-attempts = 3


This value can be changed in the application.conf with the following key:

casbah-snapshot-store.mongo-snapshot-load-attempts

# Example
casbah-snapshot-store.mongo-snapshot-load-attempts = 5

Status

  • All operations required by the Akka Persistence journal plugin API are supported.
  • All operations required by the Akka Persistence Snapshot store plugin API are supported.
  • Tested against Akka Persistence Test Kit version 0.3.4.
  • Message writes are batched to optimize throughput.
  • AtLeastOnceDelivery writes are batched to optimize throughput.
  • Mongo Sharding is not yet supported.
  • Akka-Persistence is still considered experimental and as such the underlying api may change based on changes to Akka Persistence or user feedback.

Performance

Minimal performance testing is included against a native instance. In general the journal will persist around 8,000 to 10,000 messages per second.

Sample Applications

The sample applications are now located in their own repository.

Change Log

0.7.5-SNAPSHOT

  • Upgrade sbt to 0.13.6.
  • Upgrade Scala cross-compilation to 2.10.4 & 2.11.4.
  • Upgrade Akka to 2.3.7.
  • Examples moved to their own repository.
  • Removed logback.xml in akka-persistence-mongo-casbah as it was not needed.
  • Added pomOnly() resolution to casbah dependency, fixes #63.

0.7.4

  • First release version to Maven Central Releases.
  • Upgrade Sbt to 0.13.5.
  • Upgrade Scala cross-compilation to 2.10.4 & 2.11.2.
  • Upgrade Akka to 2.3.5.
  • Added exception if /database or .collection are not accessible upon boot. Thanks @Fristi.
  • Modified snapshot feature for custom serialization support. Thanks @remcobeckers.

0.7.3-SNAPSHOT

  • Upgrade Sbt to 0.13.4.
  • Upgrade Scala cross-compilation to 2.10.4 & 2.11.2.
  • Upgrade Akka to 2.3.4.
  • @deprecated write confirmations, CasbahJournal.writeConfirmations, in favor of AtLeastOnceDelivery.
  • @deprecated delete messages, CasbahJournal.deleteMessages, per akka-persistence documentation.

Author / Maintainer

Contributors

akka-persistence-mongo's People

Contributors

aiacovella avatar buster84 avatar fristi avatar ironfish avatar rb3ckers avatar sean-walsh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.