Skip to content

ByteEntropyDotCom/resilience-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

resilience-core

Java Spring Boot Resilience4j H2 Database Maven

Virtual Threads Idempotency Status

CI/CD Pipeline

License GitHub stars GitHub forks

A robust Spring Boot library for building resilient applications with fault tolerance, circuit breakers, and retry mechanisms


Overview

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.


🚀 Key Features

Project Loom Integration -

Utilizes VirtualThreadPerTaskExecutor for lightweight, non-blocking asynchronous processing.

Layered Resilience -

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.

Idempotency Protection -

Built-in persistence layer via JPA to prevent duplicate processing of critical transactions.

Real-time Observability -

Full integration with Spring Boot Actuator and Prometheus for monitoring circuit states and failure rates.


🛠️ Technology Stack

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

📋 Prerequisites

  • JDK 21+ (Strictly required for Virtual Threads support)
  • Maven 3.9.x
  • GitHub Secrets: (Optional) Set SONAR_TOKEN and NVD_API_KEY for full CI/CD features.

⚙️ Installation & Setup

  1. Clone the Repository
  git clone https://github.com/ByteEntropyDotCom/resilience-core.git
  cd resilience-core
  1. 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
   ```

🕹️ Usage Example

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

About

A Java library for building strong, reliable apps. Built with Spring Boot 3.2.4 and Resilience4j, it helps you handle service failures with ease. Optimized for Java 21, it uses Virtual Threads to handle thousands of tasks at once without slowing down.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors