Publishing Domain Events vs Integration Events: Choosing the Right Approach

TLDRThis video explores the differences between domain events and integration events and when to use each type. It also discusses the factors of stability, understanding, and consumer requirements that should be considered when deciding on the event type.

Key insights

⚖️Domain events are specific events that occur within a service boundary, while integration events are used for integrating with other service boundaries.

🏛️Domain events are typically processed in-memory within the same transaction, while integration events are usually sent to a message broker for distribution.

🌐The decision to use domain events or integration events depends on the stability of business concepts, the understanding of the event across service boundaries, and the consumer requirements for the event type.

🔄Publishing domain events outside the service boundary is feasible if the events are stable and understood by other services, while transforming domain events into crud-based integration events can be useful for data propagation.

🏭Consider the nature of the events and whether they are part of a long-running process or a workflow when deciding between domain events and integration events.

Q&A

What are domain events?

Domain events are specific events that occur within a service boundary to notify other parts of that boundary about a state change.

What are integration events?

Integration events are events used for integrating with other service boundaries, typically sent to a message broker for distribution.

When should domain events be published outside the service boundary?

Domain events can be published outside the service boundary if they involve stable business concepts and are understood by other service boundaries.

When should domain events be transformed into integration events?

Domain events can be transformed into integration events when they are more crud-oriented and used for data propagation.

What factors should be considered when deciding between domain events and integration events?

The stability of business concepts, the understanding of the event by other services, and the consumer requirements for the event type should be considered.

Timestamped Summary

00:00Introduction to the differences between domain events and integration events.

02:30Explanation of domain events occurring within a service boundary and being processed in-memory.

06:13Discussion of integration events being used for integrating with other service boundaries and sent to a message broker.

09:23Consideration of stability, understanding, and consumer requirements when deciding on the event type.

13:43Exploration of publishing domain events outside the service boundary and transforming domain events into integration events.

16:00Importance of considering the nature of the events and their role in long-running processes or workflows.