Merge pull request #16365 from hicolour/fix-16364-doc-persistent-actor-recovery-customization-hicolour

=doc #16364 Persistent actor - clarification of the recovery cust...
This commit is contained in:
Konrad Malawski 2014-11-27 14:45:20 +01:00
commit 7b83ff5f4a
4 changed files with 44 additions and 11 deletions

View file

@ -110,6 +110,14 @@ trait PersistenceDocSpec {
}
}
new AnyRef {
trait MyProcessor1 extends PersistentActor {
//#recover-fully-disabled
override def preStart() = self ! Recover(toSequenceNr = 0L)
//#recover-fully-disabled
}
}
new AnyRef {
trait ProcessorMethods {
//#persistence-id

View file

@ -139,13 +139,13 @@ Recovery
--------
By default, a persistent actor is automatically recovered on start and on restart by replaying journaled messages.
New messages sent to a persistent actor during recovery do not interfere with replayed messages. New messages will
only be received by a persistent actor after recovery completes.
New messages sent to a persistent actor during recovery do not interfere with replayed messages.
They are cached and received by a persistent actor after recovery phase completes.
Recovery customization
^^^^^^^^^^^^^^^^^^^^^^
Automated recovery on start can be disabled by overriding ``preStart`` with an empty implementation.
Automated recovery on start can be disabled by overriding ``preStart`` with an empty or custom implementation.
.. includecode:: code/docs/persistence/PersistenceDocSpec.scala#recover-on-start-disabled
@ -153,6 +153,14 @@ In this case, a persistent actor must be recovered explicitly by sending it a ``
.. includecode:: code/docs/persistence/PersistenceDocSpec.scala#recover-explicit
.. warning::
If ``preStart`` is overriden by an empty implementation, incoming commands will not be processed by the
``PersistentActor`` until it receives a ``Recover`` and finishes recovery.
In order to completely skip recovery, you can signal it with ``Recover(toSequenceNr = OL)``
.. includecode:: code/docs/persistence/PersistenceDocSpec.scala#recover-fully-disabled
If not overridden, ``preStart`` sends a ``Recover()`` message to ``self``. Applications may also override
``preStart`` to define further ``Recover()`` parameters such as an upper sequence number bound, for example.