Backend Development 8 min read

Fast‑Retry: High‑Performance Asynchronous Multi‑Task Retry Framework for Java

Fast‑Retry is a high‑performance Java framework that enables asynchronous, multi‑task retries with both programmatic and annotation‑based APIs, dramatically improving throughput for large‑scale retry scenarios compared to traditional synchronous retry libraries.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
Fast‑Retry: High‑Performance Asynchronous Multi‑Task Retry Framework for Java

Fast‑Retry is a high‑performance, multi‑task retry framework for Java that supports asynchronous retries, allowing millions of tasks to be retried efficiently with both programmatic and annotation‑based usage patterns.

Introduction

When a system needs to poll and retry identity information for a massive number of users (e.g., one million), traditional synchronous retry libraries such as Spring‑Retry or Guava‑Retry become a bottleneck because each retry occupies a thread, leading to severe throughput degradation.

Fast‑Retry Overview

Fast‑Retry provides asynchronous retry capabilities, supporting millions of concurrent retry tasks, programmable APIs, annotation‑driven configuration, and custom result‑based retry logic.

Performance Comparison

Benchmarks with an 8‑thread pool and a task that retries five times with a 2‑second interval show that Fast‑Retry outperforms Spring‑Retry and Guava‑Retry even when those frameworks handle only 50 tasks, demonstrating exponential performance gains for large‑scale workloads.

Test thread pool: 8 fixed threads

Single task logic: 5 retries, 2‑second interval, total 10 seconds

Estimated formula: total time ≈ (task count / concurrency) × single‑task retry time

Quick Start

Dependency

<dependency>
    <groupId>io.github.burukeyou</groupId>
    <artifactId>fast-retry-all</artifactId>
    <version>0.2.0</version>
</dependency>

Using a Retry Queue

The RetryTask interface lets you define retry intervals, retry logic, and result extraction. For simple cases, prefer FastRetryBuilder or the @FastRetry annotation.

The RetryQueue acts like an executor service for scheduling retry tasks.

ExecutorService executorService = Executors.newFixedThreadPool(8);
RetryQueue queue = new FastRetryQueue(executorService);
RetryTask
task = new RetryTask
() {
    int result = 0;
    @Override
    public long waitRetryTime() { return 2000; }
    @Override
    public boolean retry() { return ++result < 5; }
    @Override
    public String getResult() { return result + ""; }
};
CompletableFuture
future = queue.submit(task);
log.info("Task finished, result:{}", future.get());

Using FastRetryBuilder

RetryResultPolicy
resultPolicy = result -> result.equals("444");
FastRetryer
retryer = FastRetryBuilder.
builder()
        .attemptMaxTimes(3)
        .waitRetryTime(3, TimeUnit.SECONDS)
        .retryIfException(true)
        .retryIfExceptionOfType(TimeoutException.class)
        .exceptionRecover(true)
        .resultPolicy(resultPolicy)
        .build();
CompletableFuture
future = retryer.submit(() -> {
    log.info("retry");
    if (0 < 10) {
        throw new TimeoutException("test");
    }
    return "444";
});
String o = future.get();
log.info("Result {}", o);

Using @FastRetry Annotation

When integrated with Spring, annotate methods with @FastRetry to let the framework generate and schedule retry tasks automatically. Enable it with @EnableFastRetry in a configuration class.

@FastRetry(retryWait = @RetryWait(delay = 2))
public String retryTask() {
    return "success";
}
@FastRetry(retryWait = @RetryWait(delay = 2))
public CompletableFuture
retryTask() {
    return CompletableFuture.completedFuture("success");
}

Custom Retry Annotation

If the built‑in annotation does not meet your needs, you can create a custom annotation that references a custom AnnotationRetryTaskFactory implementation; the default factory is FastRetryAnnotationRetryTaskFactory .

Recommendations

Prefer asynchronous retry methods that return CompletableFuture and use its whenComplete callback to handle results, ensuring non‑blocking execution.

Other Information

GitHub project: https://github.com/burukeYou/fast-retry

Maven repository: https://central.sonatype.com/artifact/io.github.burukeyou/fast-retry-all

JavaperformanceSpringasynchronousRetryAnnotationframework
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.