0

I have an event sourced system that runs on a server with clients that need to work offline from time to time. To make this work I have the domain events streamed from the server to the client when online so that the offline database is up to date in case the client goes offline. This works just fine.

When offline the user might add a new customer with the following sequence...

  1. Add new customer command.
  2. Customer aggregate added.
  3. Customer aggregate creates initial appointment aggregate.
  4. Query of read data returns new appointment details.
  5. Command used to modify the appointment.

When back online I cannot reply the events for the server. Adding the new customer is fine but the resultant new appointment has an identifier I do not know about. So trying to replay the appointment update command fails because I have no idea what the correct appointment id should be.

Any ideas?

Phil Wright
  • 22,580
  • 14
  • 83
  • 137

1 Answers1

3

You need to review Greg Young's talk CQRS, not just for server systems. Also Stack overflow question Occasionally Connected CQRS Systems, and the dddcqrs topic Merging Events in Occasionally Connected Clients.

I have no idea what the correct appointment id should be

Generate the ids when you generate the commands; you'll know what the appointment id is going to be, because you told the customer aggregate what id to use when creating the appointment.

Community
  • 1
  • 1
VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91