This question is not as philosophical as the name might suggest. Consider the following conservation approach:
Teams for performing operations come from different Clients. I represent both Operations and Clients as regular participants. The client state is lastOperationId. The state of the operation is to a large extent the FSM of the course of the operation (this is actually a saga, since then it needs to turn to other systems external to the ActorSystem in order to navigate through these states).
The receive actor receives an operation command that contains a client identifier and an operation identifier. The recipient actor creates or receives the Client’s activator and gives him a command. The client’s actor reads and verifies the work command, saves it, creates an OperationReceived event, updates its state using this operation identifier. Now he needs to create a new Operation statement to manage the new long-term operation. But here I am lost, and all the nice examples in the documentation and in different blogs do not help. Most commentators say that PersistentActor converts commands into events, and then updates their state. They may also have side effects if they are not used during the replay. So, I have two confusions:
- Is creating an acting actor in this context equivalent to creating a state or performing a side effect? This does not seem like a side effect, but at the same time it does not change its state, but causes a change in state in a new child.
- Should I build a command to send the operation to the new operator, or will I just move this OperationReceived event?
If I agree that creating a child actor is not a side effect, it means that I must also create a child on repeat play. This, in turn, will lead to the restoration of the state of the child.
I hope the main question will be clear. I think this is a general question, but I can best formulate it by giving a concrete example.
Edit : Upon reflection, I think that creating one persistent actor from another is an act of creating a state, albeit outsourced. This means that the event initiating the creation initiates this creation during subsequent reproduction (which will lead to the restoration of the child’s own saved state). This makes me think that passing an event (rather than a wrapping command) can be the purest thing, because the same event can be used to update the state of both the parent and the child. There should be no need to continue the event when it enters the child - it is already stored in the parental home and will be played.
actor akka persistence
Brendan
source share