Skip to content

[JOBS]: Introduce a transactional outbox and durable background worker #221

Description

@barry01-hash

Context

Emails, notifications, audit records, storage cleanup, and blockchain reconciliation are side effects of database changes. Executing them inline couples request success to external services; executing them after commit without durable coordination can lose work.

Scope

  • Add an outbox model written in the same transaction as domain changes.
  • Build a worker with atomic claiming, visibility timeout/lease, heartbeat, bounded retries, and dead-letter handling.
  • Define versioned event payloads and idempotent consumers.
  • Implement initial consumers for transactional email and one operational side effect.
  • Add replay, inspection, and redrive tooling with audit records.
  • Define retention and safe payload redaction.

Acceptance criteria

  • A committed domain change always leaves durable side-effect work.
  • Rolling back the domain transaction creates no outbox event.
  • Worker crashes and duplicate delivery do not duplicate logical side effects.
  • Poison messages stop retrying and remain inspectable/redrivable.
  • Queue depth, oldest age, attempts, and failures are observable.
  • Integration tests exercise concurrent workers and crash recovery.

Relevant areas

Prisma models, payout/application/support mutations, email-service.ts, future notifications and escrow reconciliation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions