Hi Konrad,
Thanks for answering so fast.
I'm not sure, I'm looking for rejecting snapshots. I would like to say I'm
looking for programmatic way to migrate an application from one format of
snapshots to another and I know prefect way how to do that by hands - just
to remove actor's snapshots (since all of them are bad now) and let actor
to recover from events. In documentation, I found only solution with
SnapshotSelectionCritera.None, but it looks for me too complicated (I
described above why).
Btw, Konrad what you think about following way (I'm competely unsure about
robustness of this solution but it works in test at least):
override def receiveRecover: Receive = {
case cmd@SnapshotOffer(metadata, offeredSnapshot: OldFormat) =>
val criteria = SnapshotSelectionCriteria(maxSequenceNr = metadata.
sequenceNr)
deleteSnapshots(criteria)
throw new IllegalArgumentException("Old snapshot found!")
case cmd@SnapshotOffer(metadata, offeredSnapshot: NewFormat) =>
state = offeredSnapshot
PS: Also ignoring of snapshot is quite dangerous and impractical from my
point of view, so I preferred to see my actor killed if snapshot was
somehow implicitly ignored (e.g. by writing case pattern match with
condition) because documentation don't stress that moment - if snapshot is
ignored only 'recent' event will be replayed (not all).
четверг, 29 декабря 2016 г., 13:38:38 UTC+2 пользователь Konrad Malawski
написал:
>
> There is no way to "reject but try a different snapshot".
> The offered snapshot is the latest one matching the criterium, and you
> either use it or not - "ignoring it".
>
> There's no "yeah not that one but another one". How would the lib know
> what you're looking for?
> Keep offering all snapshots you possibly had? Sounds rather weird.
>
> --
> Konrad `ktoso` Malawski
> Akka <http://akka.io> @ Lightbend <http://lightbend.com>
>
> On 29 December 2016 at 12:36:07, Sergey A. ([email protected]
> <javascript:>) wrote:
>
> Hi All,
>
> May be I'm missing something obvious (sorry about that - in between
> holydays week).
>
> So my problem is - persistent state of persistent actor is changed
> (evolved), so I want to recover from events if previous snapshot was taken
> from old state.
>
> Documentation says:
>
> http://doc.akka.io/docs/akka/2.4/scala/persistence.html
>
> To skip loading snapshots and replay all events you can use
>> SnapshotSelectionCriteria.None. This can be useful if snapshot
>> serialization format has changed in an incompatible way. It should
>> typically not be used when events have been deleted.
>>
>>
>> 1. override def recovery =
>> 2. Recovery(fromSnapshot = SnapshotSelectionCriteria.None)
>>
>> At first look, it's exactly what I need, but in this case I should:
>
> 1. start application with SnapshotSelectionCriteria.None and run until
> new snapshot taken
> 2. change code or configuration (to remove override)
> 3. start application again and forever (until next upgrade)
>
> if I did not perform steps 2.-3. and application will be restarted app
> will be recovered from events (soo slow).
>
> So I'm looking for something like that:
>
> Введите код... override def receiveRecover: Receive = {
> case cmd@SnapshotOffer(metadata, offeredSnapshot: OldFormat) =>
> rejectOffer
> case cmd@SnapshotOffer(metadata, offeredSnapshot: NewFormat) => state
> = offeredSnapshot
>
>
> Btw, I already tried to ignore SnapshotOffer with old type (removing 1st
> case above), but it led to worst variant - snapshot was silently bypassed
> and only recent events (not included into spanshot) replayed.
>
> Any thoughts ?
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.