Search code examples
domain-driven-designmicroservicesevent-sourcing

Event Sourcing Choregraphy that Relate to Multiple Records


I am trying to develop microservices for order / transaction process using event sourcing concept. The staff could place an order / transaction for a customer by phone. The system also record the number of order that grouped by customer. It is using AWS Kinesis to send the customer id in orderCreated event to the service of customer data so we could increment the number of created order. We separate the order processing and customer based on DDD concept. But, we should anticipate human error when staff select wrong customer id for the order. So, there is a feature to change the customer for related order.

The problem is the orderUpdated event just contains the latest data of the order. It means that the event only has the new customer id. We could increment the number of order for new customer. But, we should decrement the number of order for previous customer id.

How to solve this problem? Could you give me some suggestions?

Thanks in advance


Solution

  • It sounds like an OrderUpdated event is not granular enough to meet your needs. Based on the information you provided, you likely want to have a more specific event like OrderCustomerChanged that contains both the new and the old customer Id.