Skip to content

implement transactional outbox pattern for reliable event publishing#146

Open
kuse-design wants to merge 1 commit into
Pidoko257:mainfrom
kuse-design:feat/121-implement-transactional-outbox
Open

implement transactional outbox pattern for reliable event publishing#146
kuse-design wants to merge 1 commit into
Pidoko257:mainfrom
kuse-design:feat/121-implement-transactional-outbox

Conversation

@kuse-design

Copy link
Copy Markdown

Summary

This PR implements the Transactional Outbox Pattern to ensure reliable event publishing. Instead of publishing webhook and Redis Pub/Sub events directly within database transactions, events are first persisted to an outbox table as part of the same transaction. A relay worker then polls the outbox and publishes pending events asynchronously.

Changes

  • Added an outbox table for persisting unpublished events
  • Stored domain events in the outbox within the same database transaction as the corresponding state change
  • Implemented a relay worker to poll the outbox every second
  • Published pending events to the configured message broker
  • Marked successfully published events as processed and removed them from the outbox
  • Added safeguards to support idempotent event processing and prevent duplicate side effects
  • Followed existing project patterns and transaction boundaries

Testing

  • Verified events are written to the outbox as part of the originating database transaction
  • Verified the relay worker publishes pending events successfully
  • Verified published events are marked as processed and removed from the outbox
  • Verified duplicate event delivery does not produce duplicate side effects
  • Confirmed existing event publishing flows continue to function without regressions

Related Issue

Closes #121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Outbox Pattern for Reliable Event Publishing

1 participant