defineOutbox
Declarative transactional outbox — events written in the same DB transaction as business state, flushed to the cross-service bus by a wire-bound poller.
Signature
ts
import { defineOutbox } from "@nwire/forge";
export const ordersOutbox = defineOutbox({
name: "orders",
description: "Miri's checkout row and OrderWasPlaced share one commit.",
publishes: [OrderWasPlaced],
flushIntervalMs: 500,
maxBatch: 50,
tags: ["payments"],
});Fields
| Field | Required | Default | Purpose |
|---|---|---|---|
name | yes | — | Stable outbox id; used in Studio + storage |
description | no | — | Persona-narrated boundary story |
publishes | yes | — | Events this outbox may emit (Studio arrows) |
flushIntervalMs | no | 1000 | Hint for poller cadence |
maxBatch | no | 100 | Max entries per flush batch |
tags | no | — | Studio filtering |
Plugin registration
ts
forgePlugins({
// ... actors, projections, workflows ...
outboxes: [ordersOutbox],
});Drizzle adapter pattern
See Drizzle transactional outbox recipe for the outbox_entries table, handler transaction, and flusher wiring.
Related
defineInbox— consumer-side dedup- Idempotency
- Orchestrator boundaries