Skip to main content

implement-an-outbox-pattern

Implement an outbox pattern that atomically records domain change and event intent, then publishes with idempotency, ordering, observability, and reconciliation. Use when database state and messages must not diverge.

소스 정보

저장소
protosphinx/sphinxstack
최근 소스 활동
2026년 7월 29일 13:55
감지된 SKILL.md 언어
영어
스타
3
포크
0

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
2 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
implement-an-outbox-pattern
category
code
description
Implement an outbox pattern that atomically records domain change and event intent, then publishes with idempotency, ordering, observability, and reconciliation. Use when database state and messages must not diverge.
# implement-an-outbox-pattern Atomic intent plus replay-safe delivery replaces unreliable dual writes. ## When to use - Use when one transaction changes local state and must notify another system. - Do not claim exactly-once delivery; prove idempotent effect and reconciliation. ## Preconditions - Define transaction boundary, event contract, consumers, ordering, retention, throughput, and recovery. ## Procedure 1. Write domain change and outbox row in one local transaction. 2. Assign event ID, aggregate ID, sequence, schema version, occurred time, and safe payload. 3. Publish with claim or lease semantics that survive worker crashes. 4. Record attempts and acknowledgement without deleting the only evidence prematurely. 5. Require consumers to deduplicate event IDs and enforce aggregate ordering where needed. 6. Handle schema compatibility, poison events, retries, dead letters, and redrive. 7. Reconcile domain rows, outbox state, broker acknowledgements, and consumer outcomes. 8. Test every crash window plus backlog and recovery. ## Failure plan - Pause publishing when ordering or consumer compatibility is unsafe while retaining committed intent. ## Worked example An order and `OrderPlaced` event commit together; a crash after broker publish causes a retry that the consumer rejects by event ID. ## Done - An outbox implementation includes schema, transactional write, publisher, consumer contract, retention, reconciliation, and runbook - Rollback, duplicate, ordering, crash-window, backlog, poison, redrive, and end-to-end tests verify delivery
GitHub에서 보기