Boost Your Java Services with Fast‑Retry: High‑Performance Asynchronous Retry Framework

Fast‑Retry is a high‑performance multi‑task asynchronous retry framework for Java that outperforms traditional synchronous retry libraries like Spring‑Retry and Guava‑Retry, offering flexible APIs, annotation support, and dramatic throughput gains for massive retry scenarios.

Architect
Architect
Architect
Boost Your Java Services with Fast‑Retry: High‑Performance Asynchronous Retry Framework

Introduction

When a system has millions of users and needs to poll and retry fetching each user's identity, traditional single‑task synchronous retry frameworks such as Spring‑Retry or Guava‑Retry become impractical. Fast‑Retry is designed for this scenario.

What is Fast‑Retry?

Fast‑Retry is a high‑performance multi‑task retry framework that supports asynchronous retry for millions of tasks, offering both programmatic and annotation‑based usage and customizable result‑retry logic.

Comparison with Spring‑Retry and Guava‑Retry

Unlike the synchronous single‑task frameworks, Fast‑Retry performs asynchronous retries, avoiding thread‑pool exhaustion and delivering exponential performance gains. A benchmark shows Fast‑Retry handling 1 000 000 tasks faster than Spring‑Retry and Guava‑Retry can handle 50 tasks.

Test thread pool: 8 fixed threads

Single task logic: poll 5 times, 2 s interval, total 10 s

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

Performance comparison chart
Performance comparison chart

Quick Start

Dependency

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

Constructing Retry Tasks

Three approaches are provided:

Use a RetryQueue directly to define a RetryTask with custom retry interval, retry condition, and result retrieval.

Use FastRetryBuilder to simplify task creation.

Use the @FastRetry annotation for declarative retry, integrated with Spring.

ExecutorService executorService = Executors.newFixedThreadPool(8);
RetryQueue queue = new FastRetryQueue(executorService);
RetryTask<String> task = new RetryTask<String>() {
    int result = 0;
    @Override
    public long waitRetryTime() { return 2000; }
    @Override
    public boolean retry() { return ++result < 5; }
    @Override
    public String getResult() { return result + ""; }
};
CompletableFuture<String> future = queue.submit(task);
log.info("Task finished, result: {}", future.get());
FastRetryBuilder.<String>builder()
    .attemptMaxTimes(3)
    .waitRetryTime(3, TimeUnit.SECONDS)
    .retryIfException(true)
    .retryIfExceptionOfType(TimeoutException.class)
    .exceptionRecover(true)
    .resultPolicy(result -> result.equals("444"))
    .build()
    .submit(() -> {
        if (0 < 10) { throw new TimeoutException("test"); }
        return "444";
    });
@FastRetry(retryWait = @RetryWait(delay = 2))
public String retryTask() {
    return "success";
}

Custom Retry Annotation

You can define your own annotation based on @FastRetry and implement AnnotationRetryTaskFactory, with the default implementation being FastRetryAnnotationRetryTaskFactory.

Recommendations

Prefer asynchronous retry returning CompletableFuture and handle the result with whenComplete.

Resources

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

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

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceRetry
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

0 followers
Reader feedback

How this landed with the community

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.