giuseppe-trisciuoglio/developer-kit/spring-boot-saga-pattern
- community
Checking that the SKILL.md file is still in the repository.
Provides distributed transaction patterns using the Saga Pattern for Spring Boot microservices. Use when implementing distributed transactions across services, handling compensating transactions, ensuring eventual consistency, or building choreography or orchestration-based sagas with Kafka, RabbitMQ, or Axon Framework.
Install
npx vskill@latest install giuseppe-trisciuoglio/developer-kit/spring-boot-saga-patternSKILL.md
Spring Boot Saga Pattern
Overview
Implements distributed transactions across microservices using the Saga Pattern. Replaces two-phase commit with a sequence of local transactions and compensating actions. Supports choreography (event-driven) and orchestration (centralized coordinator) approaches with Kafka, RabbitMQ, or Axon Framework.
When to Use
- Building distributed transactions across multiple microservices
- Replacing two-phase commit (2PC) with a more scalable solution
- Handling transaction rollback when a service fails
- Ensuring eventual consistency in microservices architecture
- Implementing compensating transactions for failed operations
- Coordinating complex business processes spanning multiple services
Trigger phrases: distributed transactions, saga pattern, compensating transactions, microservices transaction, eventual consistency, rollback across services, orchestration pattern, choreography pattern
Instructions
1. Design Transaction Flow
Map the sequence of operations and their compensating transactions:
Validation: Verify every forward step has a corresponding compensation.
2. Choose Implementation Approach
| Approach | Use Case | Stack | |
|---|---|---|---|
| Choreography | Greenfield, few participants | Spring Cloud Stream + Kafka/RabbitMQ | |
| Orchestration | Complex workflows, brownfield | Axon Framework, Eventuate Tram, Camunda |
Validation: Review team expertise and system complexity before choosing.
3. Implement Services with Local Transactions
Each service completes its local ACID transaction atomically:
Validation: Test that local transaction commits before event is published.
4. Implement Compensating Transactions
Every forward operation requires an idempotent compensation:
Validation: Confirm compensation can execute safely multiple times (idempotency).
5. Set Up Message Broker
Configure Kafka with idempotent consumers:
Validation: Enable transactional ID and verify exactly-once semantics.
6. Implement Saga Orchestrator (Orchestration Only)
Validation: Verify saga state persists before sending commands. Check compensation triggers on each failure path.
7. Implement Event Handlers (Choreography Only)
Validation: Test that each event handler correctly triggers the next step or compensation.
8. Add Monitoring and Observability
Track: saga execution duration, compensation count, failure rate, stuck sagas.
Validation: Set up alerts for sagas exceeding expected duration.
Best Practices
Design:
- Make compensating transactions idempotent using database constraints or deduplication tables
- Use immutable events (Java records) to prevent accidental mutation
- Store saga state in persistent storage for recovery
Error Handling:
- Implement circuit breakers for inter-service calls
- Use dead-letter queues for messages exceeding retry limits
- Set appropriate timeouts per saga step (30s default, configurable)
Monitoring:
- Track saga status: PENDING, COMPLETED, COMPENSATING, FAILED
- Monitor compensation execution time
- Alert when sagas exceed SLA duration
Constraints and Warnings
- Every forward transaction MUST have a corresponding compensating transaction
- Compensating transactions MUST be idempotent to handle retry scenarios
- Saga state MUST be persisted to handle failures and recovery
- Never use synchronous communication between saga participants
- Sagas provide eventual consistency, not strong consistency
- Test all failure scenarios including partial failures
- Consider Axon Framework or Eventuate for complex orchestrations
- Ensure message brokers are highly available
Examples
Choreography-Based Saga
Orchestration-Based Saga with Axon Framework
References
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/developer-kit-java/skills/spring-boot-saga-pattern/SKILL.md
Popularity
- Repository stars
- 249
- Repository forks
- 27
- 7-day trend score
- 28
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/giuseppe-trisciuoglio/developer-kit/spring-boot-saga-pattern)