Domain Events vs Integration Events: When to Use Each
Fast recall
Quick revision
Core answer
DDD knowledge and understanding of event boundaries in microservices architecture
Using domain events across service boundaries — this creates tight coupling as external consumers depend on your internal domain model
Explain how domain events and integration events relate (domain event handler publishes integration event), reference DDD bounded context concept, and mention Spring's ApplicationEventPublisher for domain events
Interview-ready guide
Interview answer
Domain events and integration events both represent facts that happened, but they serve different purposes and live at different system boundaries. Understanding the distinction prevents internal refactoring from breaking other teams' pipelines.
Domain events — internal signals:
- Raised by the domain model when something meaningful happens — an order item was added, a payment was validated — and consumed by handlers in the same service, often within the same transaction
- Carry rich domain objects and are published in-memory via Spring's
ApplicationEventPublisher; they can change as fast as you refactor your internal domain model - Spring Data's
AbstractAggregateRoot.registerEvent()publishes them automatically aftersave(), keeping event raising inside the aggregate where the state transition occurs
Integration events — cross-boundary contracts:
- Cross service boundaries by being published to a message broker and consumed by other services
- Payload hygiene is critical: only primitive types, stable IDs, no references to internal domain classes; other teams don't know your domain model and should not compile against it
- A field rename in your internal domain model should never break another team's consumer — integration events prevent this by decoupling the wire format from the internal model
The translation pattern:
- A
@TransactionalEventListenerwithphase = AFTER_COMMITcatches domain events and translates them into minimal integration events using the Outbox pattern - Waiting for the commit ensures you only publish integration events for state changes that actually persisted to the database
I recommend treating integration events with the same versioning discipline as a public REST API — additive changes only, breaking changes require a migration strategy.
Domain Events vs Integration Events: When to Use Each
Direct Answer
Domain events are internal signals within a bounded context, carrying rich domain objects and published synchronously within the same transaction. Integration events cross bounded context boundaries, carry minimal data, are serialized for external consumption, and are published asynchronously via a broker. Domain events often trigger integration events.
Common Mistakes & Pitfalls
Using domain events across service boundaries — this creates tight coupling as external consumers depend on your internal domain model
Check your understanding
Answer these without looking back at the article.
- Why should integration events never carry references to internal domain objects?
- What is the role of @TransactionalEventListener vs @EventListener in Spring?
- How does DDD's bounded context concept relate to event boundaries in microservices?
Related interview prep categories
2Want a guided curriculum order?
These modules are also sequenced in our flagship backend interview track — open it when you prefer an ordered path instead of browsing by topic.