azaharizaman/nexus-outbox
Composer 安装命令:
composer require azaharizaman/nexus-outbox
包简介
Transactional outbox domain model and publish lifecycle (Layer 1).
README 文档
README
Layer 1 — transactional outbox domain model and publish lifecycle
This package defines contracts and invariants for the transactional outbox pattern: enqueue integration messages in the same unit of work as business state, then publish asynchronously with explicit pending → sending → sent | failed semantics.
It is not a message broker, queue driver, or database layer. Persistence and workers live in Layer 3 adapters. InMemoryOutboxStore is for tests and single-process use only (not a cross-process concurrency model; L3 should use row locking and unique constraints).
When to use
- You need reliable fan-out to Notifier, webhooks, analytics, or external systems after a successful commit.
- You pair with
Nexus\EventStreamwhen the system of record is an append-only stream but integrators do not consume the stream directly — seedocs/event-stream-bridge.md.
When not to use
- Event sourcing / replay of aggregate history →
Nexus\EventStream. - HTTP command idempotency (replay-safe API results) →
Nexus\Idempotency. - Exactly-once end-to-end delivery — not guaranteed; consumers must be idempotent or deduplicate (this package provides exactly-once intent at enqueue for a given dedup key within tenant scope).
Core types
| Type | Role |
|---|---|
OutboxServiceInterface |
Enqueue, claim next pending, mark sent/failed, schedule retry |
OutboxStoreInterface |
Composite query + persist (split interfaces available) |
OutboxClockInterface |
UTC now() for transitions and lease checks |
InMemoryOutboxStore |
Tests and local simulations |
Example (sketch)
use Nexus\Outbox\Domain\OutboxEnqueueCommand; use Nexus\Outbox\Services\InMemoryOutboxStore; use Nexus\Outbox\Services\OutboxService; use Nexus\Outbox\Services\SystemClock; use Nexus\Outbox\ValueObjects\DedupKey; use Nexus\Outbox\ValueObjects\EventTypeRef; use Nexus\Outbox\ValueObjects\TenantId; $tenantId = new TenantId('tenant-1'); $store = new InMemoryOutboxStore(); $clock = new SystemClock(); $outbox = new OutboxService($store, $store, $clock); $now = $clock->now(); $leaseExpiresAt = $now->modify('+5 minutes'); $result = $outbox->enqueue(new OutboxEnqueueCommand( $tenantId, new DedupKey($streamEventId), new EventTypeRef($eventTypeFqcn), $payload, $metadata, $correlationId, $causationId, $now, )); $claimed = $outbox->claimNextPending($tenantId, $leaseExpiresAt); if ($claimed !== null) { // publish to external bus, then: $outbox->markSent($tenantId, $claimed->id, $claimed->claimToken); }
Requirements
- PHP 8.3+
Related documentation
azaharizaman/nexus-outbox 适用场景与选型建议
azaharizaman/nexus-outbox 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 azaharizaman/nexus-outbox 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 azaharizaman/nexus-outbox 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-04