Distributed system

Hi group

Let's say one is building a distributed system and is evaluating CQRS/
Axon for it. The system is deployed to several sites which are
occasionally connected via sat link. there wil be messaging middelware
to handle the sending of events between those sites.

Some of the sites will be running web servers for reporting while some
other sites will be running Eclipse RCP applications accessing a local
data store.

One site will designated master, and being responsible for keeping all
aggregates in the system for restore when any site has a data loss
(disk crash ...)

Here is a scenario:
- The UI in one of the RCP apps on site A issues an AddActivityCommand
with some timing data, project id, description etc.
- A command handler on the site A server receives the command,
processes it through it's local domain, an Activity aggregate is added
to the local repository and an ActivityAddedEvent is fired.
- The ActivityAddedEvent(AAE) now travels around.
- The AAE hits the site A view database updater and the local view
database is updated.
- The AAE hits the messaging middleware and travels eventually across
to the other sites.
- On the Master site the AAE arrives on the EventBus.

And this is where I wonder what is best practice.
- Should there be an eventhandler here that issues a new
ActivityCreatedCommand for the master domain to process? This will
result in a new AAE fired here and we have a loop.



Hi Geir,

this is a pretty advanced topic, which is hard to explain by mail. So here is just a few pointers.

There should always be a “master” domain. Only that master domain is capable of emitting events to all the “slaves”. All the slaves should stage their commands. They are (of course) allowed to update their local domains using events that are generated locally.

When a “slave” connects, it sends all staged commands to the server. This might require some conflict resolution. The client then reverts any changes made locally and read in all events generated on the server to update the local model using “confirmed” events.

Does this help?