Become “should" work AFAIR, though I’d recommend using Akka 2.5 (it’s
binary compatible with 2.4, so you can just upgrade it).
I could not find if we fixed anything about become in persistent Actors,
there were fixes but a very long time ago in 2.3..

I would recommend avoiding become with PersistentActors in general, it gets
very complex.

In the Akka Typed API we’re working on for Akka Persistence become will be
*the* way to handle things and it will not be as confusing in its inner
workings as it is now.

—
Konrad `kto.so` Malawski
Akka <http://akka.io> @ Lightbend <http://lightbend.com>

On 15 September 2017 at 05:11:07, Curt Siffert (c...@keenworks.com) wrote:

Learning akka persistence, I was initially reluctant to use vars to capture
state since we generally try to avoid vars when possible.

But when experimenting with context.become(receiveBlock(stateParam)) inside
a receiveRecover implementation, it appeared to interfere with its ability
to stash other messages. (akka 2.4.20) It tried to handle normal messages
that it didn't try to handle when I wasn't using context.become.

Is it possible and reasonable to use context.become instead of var to
capture state using Akka Persistence? At first glance, it seems like the
interplay between receiveCommand and receiveRecover could get rather
tricky, especially if your actor has initialization behavior that changes
its receiveCommand behavior - for instance, initializing receiveCommand
with an empty collection to start, i.e.

def receiveCommand: Receive = initialReceive(List.empty)

Thanks,
Curt Siffert

--
>>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to