Skip to content

Commit

Permalink
Merge pull request akka#16794 from carrot-garden/persistence-multiple…
Browse files Browse the repository at this point in the history
…-plugins

+per akka#15587 Make it possible to use multiple persistence plugins
  • Loading branch information
bantonsson committed Mar 4, 2015
2 parents 33e83f9 + 18dfd39 commit 8e4f1d9
Show file tree
Hide file tree
Showing 14 changed files with 438 additions and 228 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/

package docs.persistence;

import akka.persistence.UntypedPersistentActor;

public class PersistenceMultiDocTest {

//#default-plugins
abstract class ActorWithDefaultPlugins extends UntypedPersistentActor {
@Override
public String persistenceId() { return "123"; }
}
//#default-plugins

//#override-plugins
abstract class ActorWithOverridePlugins extends UntypedPersistentActor {
@Override
public String persistenceId() { return "123"; }
// Absolute path to the journal plugin configuration entry in the `reference.conf`
@Override
public String journalPluginId() { return "akka.persistence.chronicle.journal"; }
// Absolute path to the snapshot store plugin configuration entry in the `reference.conf`
@Override
public String snapshotPluginId() { return "akka.persistence.chronicle.snapshot-store"; }
}
//#override-plugins

}
22 changes: 22 additions & 0 deletions akka-docs/rst/java/lambda-persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,25 @@ or
.. includecode:: ../scala/code/docs/persistence/PersistencePluginDocSpec.scala#shared-store-native-config

in your Akka configuration. The LevelDB Java port is for testing purposes only.

Multiple persistence plugin configurations
==========================================

By default, persistent actor or view will use "default" journal and snapshot store plugins
configured in the following sections of the ``reference.conf`` configuration resource:

.. includecode:: ../scala/code/docs/persistence/PersistenceMultiDocSpec.scala#default-config

Note that in this case actor or view overrides only ``persistenceId`` method:

.. includecode:: ../java/code/docs/persistence/PersistenceMultiDocTest.java#default-plugins

When persistent actor or view overrides ``journalPluginId`` and ``snapshotPluginId`` methods,
the actor or view will be serviced by these specific persistence plugins instead of the defaults:

.. includecode:: ../java/code/docs/persistence/PersistenceMultiDocTest.java#override-plugins

Note that ``journalPluginId`` and ``snapshotPluginId`` must refer to properly configured ``reference.conf``
plugin entires with standard ``class`` property as well as settings which are specific for those plugins, i.e.:

.. includecode:: ../scala/code/docs/persistence/PersistenceMultiDocSpec.scala#override-config
21 changes: 21 additions & 0 deletions akka-docs/rst/java/persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -666,3 +666,24 @@ Configuration
There are several configuration properties for the persistence module, please refer
to the :ref:`reference configuration <config-akka-persistence>`.

Multiple persistence plugin configurations
==========================================

By default, persistent actor or view will use "default" journal and snapshot store plugins
configured in the following sections of the ``reference.conf`` configuration resource:

.. includecode:: ../scala/code/docs/persistence/PersistenceMultiDocSpec.scala#default-config

Note that in this case actor or view overrides only ``persistenceId`` method:

.. includecode:: ../java/code/docs/persistence/PersistenceMultiDocTest.java#default-plugins

When persistent actor or view overrides ``journalPluginId`` and ``snapshotPluginId`` methods,
the actor or view will be serviced by these specific persistence plugins instead of the defaults:

.. includecode:: ../java/code/docs/persistence/PersistenceMultiDocTest.java#override-plugins

Note that ``journalPluginId`` and ``snapshotPluginId`` must refer to properly configured ``reference.conf``
plugin entires with standard ``class`` property as well as settings which are specific for those plugins, i.e.:

.. includecode:: ../scala/code/docs/persistence/PersistenceMultiDocSpec.scala#override-config
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,3 @@ persistent actor on the sending side.

Read more about at-least-once delivery in the :ref:`documentation for Scala <at-least-once-delivery>` and
:ref:`documentation for Java <at-least-once-delivery-java>`.





Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/

import akka.persistence.PersistentActor

object PersistenceMultiDocSpec {

val DefaultConfig = """
//#default-config
# Absolute path to the default journal plugin configuration entry.
akka.persistence.journal.plugin = "akka.persistence.journal.inmem"
# Absolute path to the default snapshot store plugin configuration entry.
akka.persistence.snapshot-store.plugin = "akka.persistence.snapshot-store.local"
//#default-config
"""

//#default-plugins
trait ActorWithDefaultPlugins extends PersistentActor {
override def persistenceId = "123"
}
//#default-plugins

val OverrideConfig = """
//#override-config
# Configuration entry for the custom journal plugin, see `journalPluginId`.
akka.persistence.chronicle.journal {
# Standard persistence extension property: provider FQCN.
class = "akka.persistence.chronicle.ChronicleSyncJournal"
# Custom setting specific for the journal `ChronicleSyncJournal`.
folder = ${user.dir}/store/journal
# Standard persistence extension property: plugin actor uses config injection.
inject-config = true
}
# Configuration entry for the custom snapshot store plugin, see `snapshotPluginId`.
akka.persistence.chronicle.snapshot-store {
# Standard persistence extension property: provider FQCN.
class = "akka.persistence.chronicle.ChronicleSnapshotStore"
# Custom setting specific for the snapshot store `ChronicleSnapshotStore`.
folder = ${user.dir}/store/snapshot
# Standard persistence extension property: plugin actor uses config injection.
inject-config = true
}
//#override-config
"""

//#override-plugins
trait ActorWithOverridePlugins extends PersistentActor {
override def persistenceId = "123"
// Absolute path to the journal plugin configuration entry in the `reference.conf`.
override def journalPluginId = "akka.persistence.chronicle.journal"
// Absolute path to the snapshot store plugin configuration entry in the `reference.conf`.
override def snapshotPluginId = "akka.persistence.chronicle.snapshot-store"
}
//#override-plugins

}
21 changes: 21 additions & 0 deletions akka-docs/rst/scala/persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,24 @@ Configuration
There are several configuration properties for the persistence module, please refer
to the :ref:`reference configuration <config-akka-persistence>`.

Multiple persistence plugin configurations
==========================================

By default, persistent actor or view will use "default" journal and snapshot store plugins
configured in the following sections of the ``reference.conf`` configuration resource:

.. includecode:: code/docs/persistence/PersistenceMultiDocSpec.scala#default-config

Note that in this case actor or view overrides only ``persistenceId`` method:

.. includecode:: code/docs/persistence/PersistenceMultiDocSpec.scala#default-plugins

When persistent actor or view overrides ``journalPluginId`` and ``snapshotPluginId`` methods,
the actor or view will be serviced by these specific persistence plugins instead of the defaults:

.. includecode:: code/docs/persistence/PersistenceMultiDocSpec.scala#override-plugins

Note that ``journalPluginId`` and ``snapshotPluginId`` must refer to properly configured ``reference.conf``
plugin entires with standard ``class`` property as well as settings which are specific for those plugins, i.e.:

.. includecode:: code/docs/persistence/PersistenceMultiDocSpec.scala#override-config
Loading

0 comments on commit 8e4f1d9

Please sign in to comment.