Transactional Outbox, Inbox và CDC
Outbox đóng atomicity gap giữa business update và ghi intent publish; nó không tạo single delivery.
Write path
Trong một local DB transaction: cập nhật aggregate + insert outbox row. Relay poll hoặc CDC đọc committed row rồi publish. Crash sau publish trước mark-sent tạo duplicate; consumer cần inbox/unique business key.
Ordering
Outbox cần aggregate ID, sequence/version và stable partition key nếu per-aggregate order quan trọng. Nhiều relay workers dùng locking/claiming phù hợp. Global ordering thường không cần và rất đắt.
Polling vs CDC
Polling đơn giản, portable nhưng tạo query/latency; CDC đọc transaction log hiệu quả hơn nhưng thêm platform, schema mapping và operational coupling. Cả hai cần checkpoint, poison handling và replay.
Lifecycle
Index trạng thái/created time, batch bounded, cleanup/archive sau retention và monitor oldest unpublished age. Payload schema versioned; không serialize ORM entity tùy tiện. Reconciliation so business rows với published effects.
The transactional outbox removes the atomicity gap between updating local data and recording an event to publish. It does not guarantee a single delivery, so the relay and consumers must tolerate duplicates and preserve ordering where required.