@nestarc/outbox
Transactional outbox module for NestJS — emit domain events atomically within Prisma transactions, then reliably deliver them via polling, retry, and pluggable transports.
Features
- Prisma-native — events are stored in the same
$transactionas your business data, eliminating dual-write failures - Polling with
FOR UPDATE SKIP LOCKED— multiple replicas poll concurrently without processing the same event twice @OnOutboxEvent()decorator — subscribe to events with a one-line decorator- Type-safe events — extend
OutboxEventabstract class withstatic readonly eventTypefor compile-time safety - Retry with backoff —
fixedorexponentialbackoff strategy with configurable initial delay and max retries - Stuck event recovery — events stuck in
PROCESSINGlonger thanstuckThresholdare automatically reset toPENDING - Pluggable transports —
LocalTransportfor in-process dispatch, or custom adapters (Kafka, RabbitMQ, SQS) - Batch polling — configurable
batchSizeto balance throughput and latency - Graceful shutdown — poller drains in-flight events before the process exits
- Multi-tenant ready —
tenant_idcolumn included for future@nestarc/tenancyintegration - Raw SQL migration — no Prisma model needed; ships a ready-to-run SQL file
Requirements
- NestJS 10 or 11
- Prisma 5 or 6
- PostgreSQL 9.5+ (for
SKIP LOCKEDsupport) @nestjs/schedule(peer dependency)