Skip to main content

Module outbox

Module outbox 

Source
Expand description

Outbox - Atomic commit of aggregates with publishable outbox messages.

This module provides the outbox message type and commit helpers:

  • OutboxMessage - publishable message envelope plus delivery state
  • OutboxMessageStatus - Message status (Pending, InFlight, Published, Failed)
  • OutboxCommit - Helper for aggregate + outbox commits

Outbox messages are durable publication work items. Their payload can be a domain event, integration event, command, or generic transport message. Aggregate EventRecords are replayable model history and are not automatically published as domain events.

§Separation of Concerns

The outbox pattern has two distinct phases:

  1. Commit phase (this module) - Atomically commit aggregate event records + outbox message
  2. Worker phase (see outbox_worker module) - Drain outbox and publish messages to external systems

Outbox messages are explicit publication records. Aggregate event records are replayable write-side history; they do not automatically become domain or integration events until application code creates an OutboxMessage for that publication.

§Example

use distributed::OutboxMessage;

// Create aggregate and domain event outbox message
let mut order = Order::new();
order.create("order-1", ...);

let outbox = OutboxMessage::create("order-1:created", "OrderCreated", payload);

// Commit in one async repository batch
repo.outbox(outbox).commit(&mut order).await?;

Structs§

AggregateCommit
Builder returned by AggregateRepository::outbox and AggregateRepository::read_models that commits an aggregate together with outbox rows, relational read-model writes, and (when the repository has snapshots configured) a snapshot — all in one async transactional batch.
CommitReceipt
Outcome of an outbox-bearing commit.
OutboxMessage
Durable publication work item stored through the outbox pattern.
OutboxPublisherConfig
Outbox publisher installed on a repository so commits publish immediately.

Enums§

OutboxMessageStatus
Status of an outbox message.

Constants§

OUTBOX_MESSAGES_TABLE

Traits§

OutboxPublishHook
Publishes already-committed outbox rows and settles their claims.

Functions§

outbox_message_insert_plan
outbox_message_key
outbox_message_row_values
outbox_message_schema
Schema for the durable outbox delivery table.