Domain Event vs Integration Event

Domain Event vs Integration Event

Both are "events", but they live at different scales and answer different questions. Confusing them produces tightly-coupled systems that pretend to be decoupled.

The split

Domain Event Integration Event
Scope Inside one bounded context Across bounded contexts
Transport In-process bus Message broker (Kafka, RabbitMQ, SQS, NATS)
Naming OrderPlaced (domain language) order.placed.v1 (versioned topic)
Coupling Tightly tied to the model Stable contract (versioned)
Latency Microseconds Milliseconds to seconds
Failure handling Same-transaction or compensating Retries, dead-letter, idempotency keys
Producer guarantee "Aggregate X is in state Y" "We told the broker something"
Consumer Other code in the same process Anyone subscribed to the topic
Schema Python class JSON / Avro / protobuf with explicit version

Domain Event

Emitted by an aggregate after a state change. Carries data subscribers need. Dispatched in-process. Subscribers run in the same transaction (sync) or shortly after (async, but same process).

@dataclass(frozen=True, kw_only=True)
class OrderPlaced:
    order_id: UUID
    customer_id: UUID
    total: Money
    placed_at: datetime

Used inside the Order bounded context. The Inventory subscriber inside the same context reserves stock. The Notification subscriber emails the customer.

Integration Event

Emitted across contexts, typically over a broker. Different bounded contexts speak different languages, so the integration event becomes a published contract with explicit schema and version.

// Topic: order.placed.v1
{
  "event_id": "01H...",
  "event_type": "order.placed",
  "version": 1,
  "occurred_at": "2026-06-05T10:30:00Z",
  "order_id": "...",
  "customer_id": "...",
  "total": { "amount": 4999, "currency": "USD" }
}

Used between Order and Shipping (separate context, possibly separate service). Shipping subscribes to the topic, processes asynchronously, retries on failure, deduplicates by event_id.

How they relate

A common pattern: a domain event triggers an integration event.

1. Order aggregate emits OrderPlaced (domain event)
2. In-process subscriber translates to OrderPlacedV1 (integration event)
3. Integration event published to broker
4. Shipping context consumes from broker, kicks off shipping use case

The translation step is deliberate: domain events stay coupled to the model; integration events are the stable cross-context contract.

Outbox Pattern

Publishing an integration event to a broker is itself I/O — it can fail. To keep "DB state changed" and "integration event published" consistent, write the event to an outbox table in the same transaction as the state change, and have a separate worker dispatch from the outbox to the broker.

Anti-patterns

A rule of thumb

If the event must not leave the bounded context's model, it's a domain event. If it crosses the boundary, stop and design a contract — that's now an integration event.