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 stateOutboxMessageStatus- 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:
- Commit phase (this module) - Atomically commit aggregate event records + outbox message
- Worker phase (see
outbox_workermodule) - 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§
- Aggregate
Commit - Builder returned by
AggregateRepository::outboxandAggregateRepository::read_modelsthat 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. - Commit
Receipt - Outcome of an outbox-bearing commit.
- Outbox
Message - Durable publication work item stored through the outbox pattern.
- Outbox
Publisher Config - Outbox publisher installed on a repository so commits publish immediately.
Enums§
- Outbox
Message Status - Status of an outbox message.
Constants§
Traits§
- Outbox
Publish Hook - 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.