OutboxPattern
Outbox Pattern is a software architectural pattern used to ensure reliable integration between a domain model and an external or internal event-driven messaging system. It achieves transactional integrity by persisting domain events in a dedicated storage area—typically an outbox table—within the same database transaction as the domain write. After the transaction commits, a separate process reads the outbox entries, publishes the events to the message broker (such as Kafka or RabbitMQ), and marks them as processed. This decouples the act of updating the domain model from the act of delivering messages, while keeping guarantees against message loss in the face of service outages.
Implementation usually involves: 1) writing an event record to the outbox as part of the same commit
Advantages include stronger consistency guarantees, resilience to temporary messaging failures, and simpler reasoning about transactional boundaries.