Backend Development 11 min read

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

Fast‑Retry is a high‑throughput Java retry library that enables asynchronous, non‑blocking retries for massive task volumes, offering programmable and annotation‑based APIs, custom retry policies, and significant performance gains over traditional synchronous frameworks like Spring‑Retry and Guava‑Retry.

Architect's Guide
Architect's Guide
Architect's Guide
Fast‑Retry: High‑Performance Asynchronous Retry Framework for Java

Fast‑Retry is a high‑performance, multi‑task retry framework designed for scenarios where millions of users need identity information retrieval, outperforming traditional synchronous retry libraries such as Spring‑Retry and Guava‑Retry.

Unlike those frameworks, Fast‑Retry supports asynchronous retries, timeout waiting, and callbacks, allowing massive parallelism without blocking threads.

Quick Start

Dependency

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

Fast‑Retry provides three ways to build retry tasks:

Using RetryQueue

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("任务结束 结果:{}", future.get());

Using FastRetryBuilder

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

Using @FastRetry Annotation

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

When integrated with Spring, the annotation enables proxy‑based interception of bean methods, allowing declarative retry logic.

Custom Retry Annotation

Developers can define their own retry annotation and implement AnnotationRetryTaskFactory to customize task creation; Fast‑Retry’s default factory is FastRetryAnnotationRetryTaskFactory .

Usage Recommendations

Prefer asynchronous methods that return CompletableFuture and use whenComplete to handle results.

Performance Comparison

A weather‑service benchmark shows Spring‑Retry taking ~1256 seconds for 1000 tasks, while Fast‑Retry completes in about 10 seconds, demonstrating the advantage of non‑blocking asynchronous execution.

Why Fast‑Retry Is Faster

Asynchronous execution avoids thread blocking during wait intervals.

Non‑blocking I/O reduces resource consumption.

Customizable retry policies (e.g., exponential back‑off) improve efficiency.

Optimized resource reuse (thread/connection pooling).

Rapid error detection and handling.

Easy integration and extensibility.

Avoids unnecessary retries based on error type.

Optional performance monitoring features.

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

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

BackendJavaperformanceSpringasynchronousretryFast-Retry
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

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.