I’m new to Axon, but let me first say thanks and kudos for what looks like a really useful and high-quality framework
I am looking at an application in which (in a simplified view) there’s a server and some clients. Each client holds a distinct model, and the server holds a replicated copy of every client’s model, as a single model of the whole system. Or, looked at another way, the clients each have a small subset of the server’s model.
Events can spontaneously arise in the clients (the events represent things that have happened in the real world, so I don’t think they are commands, but maybe I’m misapplying the concepts). Each event needs to update the relevant entity in that clients, then be forwarded to the server to update the server’s copy of that client’s model.
It seems like I need the events to be dispatched and applied to entities in the server, based on the ID of the entity that raised the event in the client – in much the same way that commands are dispatched based on @TargetAggregateIdentifier. Does that sound sensible, or am I missing something? Would each entity have to register itself as a listener for “it’s own” events, or does that happen automatically anyway?
The server can comfortably hold its model entirely in memory, as a single object graph. There are many entity types within the graph that will cross-reference each other a lot. To keep the business logic and consistency-checking code in the entities clean and simple, I want to use real object references as much as possible (i.e. not refer to other entities by IDs).
Does this mean that the entire object model is a single aggregate, with some sort of ‘ModelRoot’ object as the single aggregate root? Entities within the model can still be looked up and found via Repository-like interfaces; commands/events will still be dispatched to entities based on target entity IDs. Changes can be persisted into event stores as they happen, and the entire model reconstructed from events when the server restarts.
Since the entire model is in memory at once, and fully connected to itself at all times, do I really need more than one aggregate root… or any at all?
Many thanks for your help,