Skip to content

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 ​

FieldRequiredDefaultPurpose
nameyes—Stable outbox id; used in Studio + storage
descriptionno—Persona-narrated boundary story
publishesyes—Events this outbox may emit (Studio arrows)
flushIntervalMsno1000Hint for poller cadence
maxBatchno100Max entries per flush batch
tagsno—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.

MIT licensed.