Fix #16364 - Doc - Persistent actor - clarification of the recovery customization
This commit is contained in:
parent
f2487d73f4
commit
b43f3639d6
4 changed files with 44 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue