+per #15587 Make it possible to use multiple persistence plugins

This commit is contained in:
Andrei Pozolotin 2015-02-08 19:12:02 -06:00
parent a15ad56f45
commit 18dfd39686
14 changed files with 452 additions and 242 deletions

View file

@ -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
}

View file

@ -614,3 +614,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

View file

@ -667,3 +667,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