A robust Spring Boot library for building resilient applications with fault tolerance, circuit breakers, and retry mechanisms
A high-performance Spring Boot library designed for extreme fault tolerance. Resilience Core leverages Java 21's Virtual Threads (Project Loom) to handle high-concurrency external integrations without the overhead of traditional thread management.
Utilizes VirtualThreadPerTaskExecutor for lightweight, non-blocking asynchronous processing.
Pre-configured pipeline combining:
-
**Circuit Breaker: Prevents system saturation during downstream outages.
-
**Rate Limiter: Protects upstream and downstream resources.
-
**Retry Pattern: Handles transient network glitches with configurable backoff.
-
**Time Limiter: Ensures requests don't hang indefinitely.
Built-in persistence layer via JPA to prevent duplicate processing of critical transactions.
Full integration with Spring Boot Actuator and Prometheus for monitoring circuit states and failure rates.
| Technology | Version | Purpose |
|---|---|---|
| Java | 21 | Virtual Threads (Project Loom) & Modern Syntax |
| Spring Boot | 3.2.4 | Core Framework & Auto-configuration |
| Resilience4j | 2.2.0 | Fault Tolerance Patterns (Circuit Breaker, Retry, etc.) |
| JPA / H2 | Latest | Transactional Idempotency & Persistence History |
| Maven | 3.9+ | Build Automation & Dependency Management |
- JDK 21+ (Strictly required for Virtual Threads support)
- Maven 3.9.x
- GitHub Secrets: (Optional) Set
SONAR_TOKENandNVD_API_KEYfor full CI/CD features.
- Clone the Repository
git clone https://github.com/ByteEntropyDotCom/resilience-core.git
cd resilience-core-
Configure Environment (Optional) The application uses smart defaults, but you can override them in application.properties or via environment variables:
# Example: Adjusting the Circuit Breaker Threshold CB_FAILURE_THRESHOLD=50 CB_WINDOW_SIZE=10
3. Build, Test and Run
```bash
mvn clean install
mvn test
mvn spring-boot:run
```
4. Run with Docker:
```bash
# Build the image
docker build -t resilience-core .
# Run the container
docker run -p 8080:8080 resilience-core
```
The core logic resides in the ShieldPipeline, which orchestrates the resilience decorators.
```Java
@Autowired
private ShieldPipeline pipeline;
public void processPayment(PaymentRequest request) {
pipeline.execute(request)
.thenAccept(response -> log.info("Result: " + response.status()))
.exceptionally(ex -> {
log.error("Pipeline failed: " + ex.getMessage());
return null;
});
}
```
---
## 📊 Monitoring & Observability
Once running, you can monitor the health of your resilience patterns:
* **Health Status: GET /actuator/health (Shows Circuit Breaker state)
* **Metrics: GET /actuator/prometheus (Detailed failure/success counters)
* **H2 Console: localhost:8080/h2-console (JDBC URL: jdbc:h2:mem:testdb)
## 🛡️ Security & Quality
This project includes a rigorous CI/CD pipeline:
* **OWASP Dependency Check: Scans for vulnerable libraries.
* **SonarQube: Monitors code quality and technical debt.
* **Automated Tests: Ensures 100% context loading and logic verification.
---
## 📄 License
Distributed under the MIT License. See LICENSE for more information.
----
Developed with ❤️ by ByteEntropy