Lab 10: Distributed Patterns — Resilience4j
Overview
Step 1: Resilience4j Architecture
Resilience4j decorators (apply in this order for best results):
Retry → CircuitBreaker → RateLimiter → TimeLimiter → Bulkhead → Function
Circuit Breaker State Machine:
CLOSED ──(failure rate > threshold)──► OPEN
▲ │
│ (wait duration)
│ │
└──(half-open test passes)────── HALF_OPEN ──(fails)──► OPEN
RateLimiter: token bucket — limits calls per time window
Bulkhead: semaphore — limits concurrent calls
Retry: exponential backoff with jitterStep 2: Circuit Breaker
Step 3: Retry with Exponential Backoff
Step 4: Saga Pattern — Compensating Transactions
Step 5: Event Sourcing — In-Memory EventStore
Step 6: CQRS — Read/Write Models
Step 7: Outbox Pattern with SQLite
Step 8: Capstone — Resilience4j Circuit Breaker State Transitions
Summary
Pattern
Library/API
Use Case
Last updated
