| license | Apache-2.0 |
| name | distributed-transaction-manager |
| description | Saga patterns, compensating actions, and two-phase commit for distributed transactions. Activate on: distributed transaction, saga, compensating action, two-phase commit, eventual consistency, cross-service transaction. NOT for: single-database transactions (use database-connection-pool-manager), event sourcing (use cqrs-event-sourcing-architect). |
| allowed-tools | Read,Write,Edit,Bash(npm:*,npx:*,docker:*) |
| category | Backend & Infrastructure |
| tags | ["distributed-transactions","saga","compensating-actions","consistency","microservices"] |
| pairs-with | [{"skill":"cqrs-event-sourcing-architect","reason":"Event sourcing provides audit trail for saga steps"},{"skill":"event-driven-architecture-expert","reason":"Sagas coordinate via async events"},{"skill":"observability-apm-expert","reason":"Distributed tracing across saga steps is essential"}] |
Distributed Transaction Manager
Design and implement reliable cross-service transactions using saga patterns, compensating actions, and orchestrated workflows.
Activation Triggers
Activate on: "distributed transaction", "saga pattern", "compensating action", "two-phase commit", "eventual consistency", "cross-service transaction", "Temporal workflow", "rollback across services"
NOT for: Single-database ACID transactions → database-connection-pool-manager | Event sourcing → cqrs-event-sourcing-architect | Message queue setup → event-driven-architecture-expert
Quick Start
- Map the transaction boundary — identify all services that must participate
- Choose pattern — choreography saga (event-driven) or orchestration saga (central coordinator)
- Define compensating actions — every forward step needs a reverse operation
- Implement idempotency — all steps must be safely retryable
- Add timeout and dead-letter handling — no saga should hang indefinitely
Core Capabilities
| Domain | Technologies |
|---|
| Orchestration | Temporal 1.25+, Step Functions, Conductor |
| Choreography | Kafka events, RabbitMQ, Redis Streams |
| Frameworks | NestJS Saga, MassTransit (.NET), Axon (JVM) |
| State Machines | XState 5.x, custom saga state tables |
| Monitoring | Temporal UI, saga state dashboards |
Architecture Patterns
Orchestration Saga (Temporal)
Saga Orchestrator (Temporal Workflow)
│
├─→ Step 1: Reserve Inventory ──fail──→ (no compensation needed)
│ ↓ success
├─→ Step 2: Charge Payment ──fail──→ Compensate: Release Inventory
│ ↓ success
├─→ Step 3: Create Shipment ──fail──→ Compensate: Refund Payment
│ ↓ success Compensate: Release Inventory
└─→ COMPLETE
import { proxyActivities } from ;
{ reserveInventory, releaseInventory,
chargePayment, refundPayment,
createShipment } = proxyActivities<>({
: ,
: { : },
});
(): <> {
(order.);
{
paymentId = (order.);
{
shipmentId = (order.);
{ : , paymentId, shipmentId };
} {
(paymentId);
();
}
} {
(order.);
();
}
}