GithubHelp home page GithubHelp logo

asyncretryable's Introduction

AsyncRetryable 异步可持久化的任务重试工具

org.springframework.retry.annotation.Retryable的功能相似,当方法抛出指定的异常后会进行重试。
最大的区别在于,该工具会将失败的任务进行持久化(比如存储到mysql数据库中),当系统重启后任务依然可以继续执行。

特性

重试操作是异步执行的

这点非常重要,也就是当方法失败后,不会抛出异常而是会继续向后执行,重试操作会在任务线程中被触发。
目前任务线程设计为单线程的,任务会被循环串行执行,这是因为该工具被设计为去处理一些简单的低耗时的任务。

任务是持久化存储的

这也就表示即使系统重启任务依然可以被继续执行。
以及如果你进行了多节点的集群部署,那么任务数据将被共享执行。

使用

在需要重试的方法上添加注解@AsyncRetryable,被注解的方法参数必须为BaseTaskParam的子类

DEMO

执行测试方法 top.rizon.WebApplicationTest.main()
在该DEMO中,为了方便演示,实现了一个基于内存的持久化方案(top.rizon.MemTaskHelper)

asyncretryable's People

Contributors

othorizon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

cckmit

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.