Skip to content

Commit 80aa3a3

Browse files
authored
docs: update icons (#52)
1 parent 4470311 commit 80aa3a3

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ A scheduler or worker then reliably sends these messages to Zeebe after the tran
8383
Track completed operations to prevent duplicate processing when Zeebe retries job workers.
8484
Uses a database table to record which operations have been completed.
8585

86-
### **4. Saga Pattern** 🔄
86+
### **4. Saga Pattern**
8787

8888
Handle distributed transaction rollbacks using BPMN compensation events.
8989
When a later step fails, compensation handlers automatically undo previously completed operations.

examples/saga-pattern/README.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 🔄 Saga Pattern with BPMN Compensation
1+
# Saga Pattern with BPMN Compensation
22

33
This example demonstrates how to handle **distributed transaction rollbacks** using the saga pattern with BPMN
44
compensation events. When a later step in a process fails, compensation handlers can reliably undo previously completed
@@ -49,40 +49,53 @@ non-persistent state:
4949

5050
**Spot Management (Limited Resource):**
5151

52-
- **[InMemoryNewsletterSpotManager](src/main/kotlin/de/emaarco/example/adapter/out/memory/InMemoryNewsletterSpotManager.kt)** - In-memory manager tracking 50 subscriber spots using `mutableSetOf<Email>`
53-
- Spots are reserved or released (compensated) based on payment outcome
54-
- Demonstrates realistic limited resource constraint
52+
- [InMemoryNewsletterSpotManager](src/main/kotlin/de/emaarco/example/adapter/out/memory/InMemoryNewsletterSpotManager.kt):
53+
In-memory manager tracking 50 subscriber spots using `mutableSetOf<Email>`.
54+
- Spots are reserved or released (compensated) based on payment outcome. Demonstrates realistic limited resource
55+
constraint.
5556

5657
**Key Services:**
5758

58-
1. **[SubscribeToPayedNewsletterService](src/main/kotlin/de/emaarco/example/application/service/SubscribeToPayedNewsletterService.kt)** - Entry point that checks spot availability, persists subscription to DB, and publishes message to Zeebe
59-
2. **[ReserveSpotService](src/main/kotlin/de/emaarco/example/application/service/ReserveSpotService.kt)** - Reserves spot in memory (compensatable operation)
60-
3. **[ProcessPaymentService](src/main/kotlin/de/emaarco/example/application/service/ProcessPaymentService.kt)** - Uses `Random.nextBoolean()` to simulate payment success/failure, persists result to DB
61-
4. **[CancelReservationService](src/main/kotlin/de/emaarco/example/application/service/CancelReservationService.kt)** - **Compensation handler** that releases spot back to available pool
62-
5. **[SendWelcomeMailService](src/main/kotlin/de/emaarco/example/application/service/SendWelcomeMailService.kt)** - Logs welcome mail on successful payment
59+
1. [SubscribeToPayedNewsletterService](src/main/kotlin/de/emaarco/example/application/service/SubscribeToPayedNewsletterService.kt):
60+
Entry point that checks spot availability, persists subscription to DB, and publishes message to Zeebe
61+
62+
2. [ReserveSpotService](src/main/kotlin/de/emaarco/example/application/service/ReserveSpotService.kt): Reserves spot
63+
in memory (compensatable operation)
64+
3. [ProcessPaymentService](src/main/kotlin/de/emaarco/example/application/service/ProcessPaymentService.kt): Uses
65+
`Random.nextBoolean()` to simulate payment success/failure, persists result to DB
66+
4. [CancelReservationService](src/main/kotlin/de/emaarco/example/application/service/CancelReservationService.kt):
67+
Compensation handler that releases spot back to available pool
68+
5. [SendWelcomeMailService](src/main/kotlin/de/emaarco/example/application/service/SendWelcomeMailService.kt): Logs
69+
welcome mail on successful payment
6370

6471
**Zeebe Job Workers:**
6572

66-
- **[ReserveSpotWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/ReserveSpotWorker.kt)** - Handles `newsletter.reserveSpot` job type
67-
- **[ProcessPaymentWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/ProcessPaymentWorker.kt)** - Handles `newsletter.processPayment` job type
68-
- **[CancelReservationWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/CancelReservationWorker.kt)** - Handles `newsletter.cancelSpot` compensation job type, triggered automatically by Zeebe
69-
- **[SendWelcomeMailWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/SendWelcomeMailWorker.kt)** - Handles `newsletter.sendWelcomeMail` job type
73+
- **[ReserveSpotWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/ReserveSpotWorker.kt)**: Handles
74+
`newsletter.reserveSpot` job type
75+
- **[ProcessPaymentWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/ProcessPaymentWorker.kt)**: Handles
76+
`newsletter.processPayment` job type
77+
- **[CancelReservationWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/CancelReservationWorker.kt)**: Handles
78+
`newsletter.cancelSpot` compensation job type, triggered automatically by Zeebe
79+
- **[SendWelcomeMailWorker](src/main/kotlin/de/emaarco/example/adapter/in/zeebe/SendWelcomeMailWorker.kt)**: Handles
80+
`newsletter.sendWelcomeMail` job type
7081

7182
**REST API:**
7283

73-
- **[SubscribeToPayedNewsletterController](src/main/kotlin/de/emaarco/example/adapter/in/rest/SubscribeToPayedNewsletterController.kt)** - Exposes `POST /api/payed-newsletter/subscribe` endpoint
84+
- [SubscribeToPayedNewsletterController](src/main/kotlin/de/emaarco/example/adapter/in/rest/SubscribeToPayedNewsletterController.kt):
85+
Exposes `POST /api/payed-newsletter/subscribe` endpoint
7486

7587
**Process Adapter:**
7688

77-
- **[PayedNewsletterProcessAdapter](src/main/kotlin/de/emaarco/example/adapter/out/zeebe/PayedNewsletterProcessAdapter.kt)** - Publishes `Message_FormSubmitted` to start the process instance
89+
- [PayedNewsletterProcessAdapter](src/main/kotlin/de/emaarco/example/adapter/out/zeebe/PayedNewsletterProcessAdapter.kt):
90+
Publishes `Message_FormSubmitted` to start the process instance
7891

7992
**BPMN Configuration:**
8093

8194
The [`payed-newsletter.bpmn`](../../configuration/payed-newsletter.bpmn) model defines the compensation structure:
8295

83-
- `serviceTask_reserveSpot` - Compensatable activity with boundary compensation event
84-
- `serviceTask_cancelReservation` - Compensation handler marked with `isForCompensation="true"`
85-
- `endEvent_paymentFailed` - End event that triggers compensation via `compensateEventDefinition`
96+
- `serviceTask_reserveSpot`: Compensatable activity with boundary compensation event
97+
- `serviceTask_cancelReservation`: Compensation handler marked with `isForCompensation="true"`
98+
- `endEvent_paymentFailed`: End event that triggers compensation via `compensateEventDefinition`
8699

87100
## **Sequence Flow** 📊
88101

@@ -187,4 +200,4 @@ rollbacks when failures occur, ensuring consistency across your distributed syst
187200

188201
While more complex than simple database transactions, sagas are essential for building resilient microservice
189202
architectures where operations span multiple independent systems that cannot participate in traditional ACID
190-
transactions.
203+
transactions.

0 commit comments

Comments
 (0)