I would like to clarify in my mind the way different kinds of events could be implemented in a EDA system (system with Event Driven Architecture) implementing DDD (Domain Driven Design). Let assume that we are not using event sourcing.

More specifically having read relevant articles it seems there are 3 kinds of events:

  • Event notification: This kind of event seems not to carry much details, it just notifies the for the event which has happened, providing a way to query for more information.

"type": "paycheck-generated",
"event-id": "537ec7c2-d1a1-2005-8654-96aee1116b72", 
"delivery-id": "05011927-a328-4860-a106-737b2929db4e", 
"timestamp": 1615726445,
"payload": {
"employee-id": "456123",
"link": "/paychecks/456123/2021/01" }
}
  • Event-carried state transfer (ECST): This event seems to come in two flavours, either it has a delta of some information which was changed, or it contains all the relevant information (snapshot) for a resource.
{
"type": "customer-updated",
"event-id": "6b7ce6c6-8587-4e4f-924a-cec028000ce6", 
"customer-id": "01b18d56-b79a-4873-ac99-3d9f767dbe61", 
"timestamp": 1615728520,
"payload": {
"first-name": "Carolyn", 
"last-name": "Hayes",
"phone": "555-1022",
"status": "follow-up-set", 
"follow-up-date": "2021/05/08", 
"birthday": "1982/04/05", 
"version": 7
 } 
}
{
"type": "customer-updated",
"event-id": "6b7ce6c6-8587-4e4f-924a-cec028000ce6", 
"customer-id": "01b18d56-b79a-4873-ac99-3d9f767dbe61", 
"timestamp": 1615728520,
"payload": {
"status": "follow-up-set", 
"follow-up-date": "2021/05/10", 
"version": 8
} 
}
  • Domain event: This event lies somewhere in between on both of the other two, it has more information than the event notification but this info is more relevant to a specific domain.

The examples above for each one from the Khononov's book (Learning Domain-Driven Design: Aligning Software Architecture and Business Strategy)

Having said the previous statements I would like to clarify the following questions:

(1) Is the typical use of the Event-carried state transfer (ECST) and Event notifications type of events to be used in the form of integration events (in a DDD EDA system) when communicating with other bounded contexts? (via transforming domain events to integration events depending on the use case)

(2) Is there one or many other typical categories of events in a Domain Driven Designed system utilising Event Driven Architecture? For example: event notifications when domain errors occur - for client notification for the specific error (which in this case there is no aggregate persistence taking place) - how are these kind of errors are propagated back to the client, and what could be the name of such events accepted by the DDD EDA community?

1

There are 1 best solutions below

0
Ricardo Ferraris On

I would say that there are two different types of Events: Domain Events and Application (or Integration) Events.

A Domain Event is effectively a change in the domain. If we have a Person aggregate then some Domain Events could be "Person First Name Changed", "Person Last Name Changed", "Person Email Changed". Now, the interface of the Event is up to you, you can either emit the ID of the Aggregate and let the clients retrieve the updated values thru an API or similar, or you can emit what has changed (e.g. if "Person First Name Changed" is emitted then sending the new first name).

An Application Event is an Event that is emitted because something happened at application level. Imagine that we have an UpdatePersonDetails use case. In this use case there could be a lot of modifications to Person: first name, last name, email. Besides emitting the Domain Event you may want to emit an Event when this use case gets executed as a whole because it may be important for your business.

For your question number 2: if there is no changes in the Aggregate then it is certainly not a Domain Event (unless that the failure has a business concept) but rather an Application Event. In this case you could emit something like "Update Person Use Case Failed" event.