GithubHelp home page GithubHelp logo

easy-retry's Introduction

Easy-Retry

一种存储介质可扩展的持久化重试方案 img

Getting started

Memory Retry

  1. 增加pom依赖
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>easy-retry-memory-starter</artifactId>
    <version>${last-version}</version>
</dependency>
  1. 在application.properties增加配置

spring.easyretry.memory.enabled = true

  1. 在需要重试的方法上增加@EasyRetryable注解
public class MemoryUserService {
    @EasyRetryable
    public User getUserById(Long userId){
        return new User();
    }
}

Mybatis Retry

  1. 增加pom依赖
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>easy-retry-mybatis-starter</artifactId>
    <version>${last-version}</version>
</dependency>
  1. 在application.properties增加配置

spring.easyretry.mybatis.enabled = true

  1. 声明javax.sql.DataSourceBean实例,参考下面例子(以druid连接池为例)
@Bean(name = "easyRetryMybatisDataSource", initMethod = "init", destroyMethod = "close")
public DataSource easyRetryMybatisDataSource() {
    DruidDataSource tds = new DruidDataSource();
    tds.setUrl("");
    tds.setUsername("");
    tds.setPassword("");
    ...
    return tds;
}
  1. 新增持久化表
CREATE TABLE `easy_retry_task` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  `gmt_create` datetime NOT NULL COMMENT '创建时间',
  `gmt_modified` datetime NOT NULL COMMENT '修改时间',
  `sharding` varchar(64) DEFAULT NULL COMMENT '数据库分片字段',
  `biz_id` varchar(64) DEFAULT NULL COMMENT '业务id',
  `executor_name` varchar(512) NOT NULL COMMENT '执行名称',
  `executor_method_name` varchar(512) NOT NULL COMMENT '执行方法名称',
  `retry_status` tinyint(4) NOT NULL COMMENT '重试状态',
  `args_str` varchar(7168) DEFAULT NULL COMMENT '执行方法参数',
  `ext_attrs` varchar(3000) DEFAULT NULL COMMENT '扩展字段',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COMMENT='easy_retry_task'
;
  1. 在需要重试的方法上增加@EasyRetryable注解
public class MybatisUserService {
    @EasyRetryable
    public User getUserById(Long userId){
        return new User();
    }
}

Built With

• JDK1.8

• Spring Framework5+

• Spring Boot2.4+

• Maven3.0

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.