Code Monkey home page Code Monkey logo

easy-retry's Introduction

retry

定时扫描重试记录,实现重试功能

使用示例

使用内存存储记录重试

RetryHandler<String, String, String> handler  = (group, key, s) -> {
    CompletableFuture<String> future = new CompletableFuture<>();
    // 可以启动线程执行重试逻辑
    ...
    // 执行结束设置结果
    future.complete("retry");
    // future.completeExceptionally(new Throwable("err"));
    return future;
};

Retry<String, String, String> retry = new Retry<>(new MemoryStorage(new ConcurrentHashMap<>(), ArrayDeque::new)), handler);
retry.start();
...
// 加入重试队列
retry.push("topic1" , "some data");


// 应用关闭时
retry.shutdown();

持久化存储重试记录

// 添加依赖
implementation 'org.rocksdb:rocksdbjni:6.7.3'

替换storage

RocksDBStorage db = new RocksDBStorage("any path");
db.open();

// 应用关闭时
db.close();

实现了简单的 Kafka 消息重发逻辑

KafkaTemplate<String, String>                     template;

DefaultKafkaRetryHandler<String, String>          handler  = new DefaultKafkaRetryHandler<>(template);
Retry<String, String, SendResult<String, String>> retry   = new Retry<>(handler);
...

easy-retry's People

Contributors

shenluw avatar

Watchers

James Cloos avatar  avatar

Forkers

ypsliu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.