Edward Yakop wrote:
Would the command handler knows that it's being invoked in "replaying" context?
E.g. if part of the business logic is to send sms notification for example.
We don't want to invoke that sms notification routine during replay.
Same question applies to event.
SMS notification and building up a model snapshot are both examples of
handling events caused by commands. When you are recreating the snapshot
you are therefore not recreating the events, just playing them again.
The SMS notification should not be done by the model itself, but rather
something external that also listens to the events (i.e. the domain
model and the SMS notification are both consumers of events). This way
there is no risk that replaying the events to create the snapshot does
anything but that.
But this needs to be kept in mind when creating the domain model, so
that things like SMS notification are not accidentally built into the
domain model itself, but rather kept outside of it. The simple rule is
that the domain model cannot use any services, and therefore is not able
to call the SMS service. The only thing it can do is build up the state
of the domain model.
Commands are methods on Entities.
Entity can be created and deleted.
If command are methods on entities.
Who will handle the "creational" command?
Good question. My current take on that is that one will have to create a
root entity with a given id when the system is started, so that there is
always something that can be used to create the new entities.
But this might be entirely wrong. It might be that command execution is
something entirely separate from the entities themselves, i.e. should be
in services or similar.
So, what are we saying?
With a correct setup of Event (or Command) recording, it is possible
to restore the Entity Store state. If you use the suggested
event/command system, it is recommended that you consider the
EntityStore a "snapshot" of the current state, and the real state is
recorded as a sequence of events in the domain model. Hence, the
"snapshot" may be zapped, playback the event log and you will have the
EntityStore snapshot back with same values.
As long as we don't deal with "remote" service?
Can replay be orchestrated with remote qi4j application?
This is probably a non-concern atm.
Not sure what you mean here. Can you clarify further?
/Rickard
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev