Backend Development 7 min read

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

Fast‑Retry is a high‑performance Java library that enables asynchronous, multi‑task retry with customizable policies, offering dramatically better throughput than traditional synchronous retry frameworks like Spring‑Retry and Guava‑Retry for large‑scale user‑identity polling scenarios.

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

Fast‑Retry is a high‑performance, multi‑task retry framework designed for Java back‑end systems that need to process massive numbers of retryable operations, such as polling identity information for millions of users.

Unlike traditional synchronous retry libraries (e.g., Spring‑Retry, Guava‑Retry) which handle each retry as a separate blocking task, Fast‑Retry operates asynchronously, allowing millions of tasks to be retried concurrently with minimal thread consumption.

The framework supports both programmatic and annotation‑based usage, custom result‑based retry policies, and integrates easily with existing thread pools.

Quick Start

Dependency

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

There are three main ways to create retry tasks:

Using a RetryQueue – the core scheduler similar to an ExecutorService.

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 – a fluent builder that hides the RetryQueue details.

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("重试");
    if (0 < 10) {
        throw new TimeoutException("test");
    }
    return "444";
});
String o = future.get();
log.info("结果{}", o);

Using @FastRetry Annotation – integrates with Spring beans; enable with @EnableFastRetry and annotate methods with @FastRetry . The annotation can be customized via a user‑defined AnnotationRetryTaskFactory .

All approaches are recommended to return a CompletableFuture and handle completion with whenComplete for true asynchronous execution.

Other Resources

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

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

backendJavaperformanceasynchronousRetryFast-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.