Persistence.Instance.Apply(Sys as ExtendedActorSystem).JournalFor(null)
TestProbe
or with the Cluster
plugin not publishing events properly?
ClusterDomainEventPublisher
today
I'm still trying to reload state in a test of PersistentFSM actor. It looks like the state is being loaded in correctly, but then when I try to send another message to the same actor it looks like the state is back to the initial state again. I've put together a cut down example that demonstrates my problem.
Basically the actor counts and should change state on receiving the 3rd message, which I'm trying to set up with the following:
journal.Tell(new WriteMessages(new[]
{
new Akka.Persistence.AtomicWrite(ImmutableList.Create<IPersistentRepresentation>(
new Persistent(new CountedEvent(1), 1, "testActorId"),
new Persistent(new CountedEvent(2), 2, "testActorId"),
new Persistent(new CountedEvent(3), 3, "testActorId"),
new Persistent(new PersistentFSMBase<TestActorState, TestActorData, object>.StateChangeEvent(TestActorState.FinishedCounting, null), 4, "testActorId")
))
}, testActor, ActorInstanceId));
The full code is here:
https://gist.github.com/finnnewick-justgiving/b0167b55a33d0259ec7907d38fbc2ed2
Any ideas? I'm guessing I'm missing something very basic as I'm pretty new to akka.net.
ExpectMsg
to ensure, that they have been stored, and THEN create a persistent actor. Remember that sending a message is asynchronous process, so sending events to journal and command to persistent actor will be done in parallel.
this is the line in question that's not doing what I would expect it to:
new Persistent(new PersistentFSMBase<TestActorState, TestActorData, object>.StateChangeEvent(TestActorState.FinishedCounting, null), 4, "testActorId")
When(TestActorState.FinishedCounting, (e, state) =>