SOLID & Design Patterns Interview Question #75

What is the difference between a Domain Event and an Integration Event?

Advanced Patterns, CQRS & Domain-Driven Design Fundamentals Mid-Level Intermediate

Quick Interview Answer

A Domain Event represents an occurrence within a domain model and is often used for communication inside the same application or bounded context. An Integration Event is intended to communicate an occurrence across application, service, or bounded-context boundaries.

Detailed Explanation

A Domain Event represents an occurrence within a domain model and is often used for communication inside the same application or bounded context. An Integration Event is intended to communicate an occurrence across application, service, or bounded-context boundaries.

Integration events usually require stronger concerns around serialization, versioning, delivery reliability, idempotency, and messaging infrastructure. A domain event may lead to an integration event, but they serve different boundaries.

Code Example

// Domain event
public record OrderConfirmedDomainEvent(Guid OrderId);

// Integration event
public record OrderConfirmedIntegrationEvent(
    Guid OrderId,
    DateTime OccurredAtUtc,
    int Version);