refactor: 代码去easy-retry化

This commit is contained in:
dhb52 2024-04-16 15:03:52 +08:00
parent 44f6bf8672
commit bbf8924fe4
64 changed files with 338 additions and 344 deletions

2
.gitignore vendored
View File

@ -29,3 +29,5 @@ HELP.md
.vscode/ .vscode/
.flattened-pom.xml .flattened-pom.xml
/data/

View File

@ -119,7 +119,7 @@
</dependencies> </dependencies>
<build> <build>
<finalName>easy-retry-example</finalName> <finalName>snail-job-example</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -1,55 +0,0 @@
package com.example.easy.retry.config;
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author: www.byteblogs.com
* @date : 2023-07-17 18:19
* @since 2.1.0
*/
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("Easy Retry Example")
.description("<h1>EasyRetry是致力提高分布式业务系统一致性的分布式重试平台</h1> \n" +
"<h3>官网地址: https://www.easyretry.com/</h3>" +
"<h3>在线体验地址: http://preview.easyretry.com/</h3> " +
"<h3>源码地址: https://gitee.com/byteblogs168/easy-retry-demo</h3>" +
"<h3>特别提醒: 🌻在您使用测试案例之前请认真的阅读官网.</h3>")
.version(EasyRetryVersion.getVersion())
.license(new License().name("Apache 2.0").url("https://www.easyretry.com/")))
.externalDocs(new ExternalDocumentation()
.description("视频教程:从0到1快速了解分布式重试组件EasyRetry")
.url("https://www.ixigua.com/pseries/7272009348824433213/"))
;
}
@Bean
public GroupedOpenApi adminApi() {
return GroupedOpenApi.builder()
//分组名
.group("user")
.pathsToMatch("/**")
//扫描路径将路径下有swagger注解的接口解析到文档中
.packagesToScan("com.example.easy.retry.controller")
.build();
}
}

View File

@ -1,19 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.SnailChannelReconnectEvent;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 21:58:18
* @since 3.1.0
*/
@Component
public class EasyRetryChannelReconnectListener implements ApplicationListener<SnailChannelReconnectEvent> {
@Override
public void onApplicationEvent(SnailChannelReconnectEvent event) {
EasyRetryLog.LOCAL.info("这个一个重连事件");
}
}

View File

@ -1,19 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.SnailClientClosedEvent;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class EasyRetryClosedListener implements ApplicationListener<SnailClientClosedEvent> {
@Override
public void onApplicationEvent(SnailClientClosedEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry关闭完成事件");
}
}

View File

@ -1,19 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.SnailClientClosingEvent;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class EasyRetryClosingListener implements ApplicationListener<SnailClientClosingEvent> {
@Override
public void onApplicationEvent(SnailClientClosingEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry开始关闭事件");
}
}

View File

@ -1,19 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.SnailClientStartedEvent;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class EasyRetryStartedListener implements ApplicationListener<SnailClientStartedEvent> {
@Override
public void onApplicationEvent(SnailClientStartedEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry启动完成事件");
}
}

View File

@ -1,19 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.SnailClientStartingEvent;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class EasyRetryStartingListener implements ApplicationListener<SnailClientStartingEvent> {
@Override
public void onApplicationEvent(SnailClientStartingEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry启动事件");
}
}

View File

@ -1,6 +1,6 @@
package com.example.easy.retry; package com.example.snailjob;
import com.aizuda.easy.retry.client.starter.EnableEasyRetry; import com.aizuda.snailjob.client.starter.EnableSnailJob;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -8,13 +8,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.TimeZone; import java.util.TimeZone;
@SpringBootApplication @SpringBootApplication
@EnableEasyRetry(group = "easy_retry_demo_group") @EnableSnailJob(group = "snail_job_demo_group")
@MapperScan("com.example.easy.retry.dao") @MapperScan("com.example.snailjob.dao")
public class EasyRetrySpringbootApplication { public class SnailJobSpringbootApplication {
public static void main(String[] args) { public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
SpringApplication.run(EasyRetrySpringbootApplication.class, args); SpringApplication.run(SnailJobSpringbootApplication.class, args);
} }
} }

View File

@ -0,0 +1,55 @@
package com.example.snailjob.config;
import com.aizuda.snailjob.common.core.util.SnailJobVersion;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author: www.byteblogs.com
* @date : 2023-07-17 18:19
* @since 2.1.0
*/
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("Snail Job Example")
.description("<h1>SnailJob是致力提高分布式业务系统一致性的分布式重试平台</h1> \n" +
"<h3>官网地址: https://www.easyretry.com/</h3>" +
"<h3>在线体验地址: http://preview.easyretry.com/</h3> " +
"<h3>源码地址: https://gitee.com/byteblogs168/easy-retry-demo</h3>" +
"<h3>特别提醒: 🌻在您使用测试案例之前请认真的阅读官网.</h3>")
.version(SnailJobVersion.getVersion())
.license(new License().name("Apache 2.0").url("https://www.easyretry.com/")))
.externalDocs(new ExternalDocumentation()
.description("视频教程:从0到1快速了解分布式重试组件EasyRetry")
.url("https://www.ixigua.com/pseries/7272009348824433213/"))
;
}
@Bean
public GroupedOpenApi adminApi() {
return GroupedOpenApi.builder()
//分组名
.group("user")
.pathsToMatch("/**")
//扫描路径将路径下有swagger注解的接口解析到文档中
.packagesToScan("com.example.easy.retry.controller")
.build();
}
}

View File

@ -1,6 +1,6 @@
package com.example.easy.retry.controller; package com.example.snailjob.controller;
import com.example.easy.retry.service.LocalRemoteService; import com.example.snailjob.service.LocalRemoteService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,6 +1,6 @@
package com.example.easy.retry.controller; package com.example.snailjob.controller;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.example.easy.retry.service.LocalRetryService; import com.example.snailjob.service.LocalRetryService;
@RestController @RestController
@RequestMapping("/local") @RequestMapping("/local")

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.controller; package com.example.snailjob.controller;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.example.easy.retry.service.ManualRetryExecutorMethodService; import com.example.snailjob.service.ManualRetryExecutorMethodService;
@RestController @RestController
@RequestMapping("/manual") @RequestMapping("/manual")

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.controller; package com.example.snailjob.controller;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
@ -16,8 +16,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
import com.example.easy.retry.service.RemoteRetryService; import com.example.snailjob.service.RemoteRetryService;
@RestController @RestController
@RequestMapping("/remote") @RequestMapping("/remote")

View File

@ -1,6 +1,6 @@
package com.example.easy.retry.controller; package com.example.snailjob.controller;
import com.aizuda.easy.retry.server.model.dto.CallbackParamsDTO; import com.aizuda.snailjob.server.model.dto.CallbackParamsDTO;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.customized; package com.example.snailjob.customized;
import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.easy.retry.common.core.model.IdempotentIdContext; import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@ -1,13 +1,12 @@
package com.example.easy.retry.customized; package com.example.snailjob.customized;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback; import com.aizuda.snailjob.client.core.callback.RetryCompleteCallback;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.example.snailjob.dao.FailOrderBaseMapper;
import com.example.easy.retry.dao.FailOrderBaseMapper; import com.example.snailjob.po.FailOrderPo;
import com.example.easy.retry.po.FailOrderPo; import com.example.snailjob.vo.OrderVo;
import com.example.easy.retry.vo.OrderVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@ -1,10 +1,8 @@
package com.example.easy.retry.customized; package com.example.snailjob.customized;
import org.apache.catalina.security.SecurityUtil; import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; import com.example.snailjob.vo.OrderVo;
import com.aizuda.easy.retry.common.core.model.IdempotentIdContext;
import com.example.easy.retry.vo.OrderVo;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;

View File

@ -1,11 +1,9 @@
package com.example.easy.retry.customized; package com.example.snailjob.customized;
import java.lang.reflect.Array;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.strategy.ExecutorMethod; import com.aizuda.snailjob.client.core.strategy.ExecutorMethod;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@ -1,8 +1,7 @@
package com.example.easy.retry.customized; package com.example.snailjob.customized;
import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.easy.retry.common.core.model.IdempotentIdContext; import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
import com.example.easy.retry.vo.OrderVo;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;

View File

@ -1,9 +1,9 @@
package com.example.easy.retry.dao; package com.example.snailjob.dao;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.easy.retry.po.FailOrderPo; import com.example.snailjob.po.FailOrderPo;
@Repository @Repository
public interface FailOrderBaseMapper extends BaseMapper<FailOrderPo> { public interface FailOrderBaseMapper extends BaseMapper<FailOrderPo> {

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.exception; package com.example.snailjob.exception;
/** /**
* 业务异常类 * 业务异常类

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.exception; package com.example.snailjob.exception;
/** /**
* 参数异常处理类 * 参数异常处理类
*/ */

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.executor; package com.example.snailjob.executor;
import com.aizuda.easy.retry.client.core.annotation.ExecutorMethodRegister; import com.aizuda.snailjob.client.core.annotation.ExecutorMethodRegister;
import com.aizuda.easy.retry.client.core.strategy.ExecutorMethod; import com.aizuda.snailjob.client.core.strategy.ExecutorMethod;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.handler; package com.example.snailjob.handler;
import com.aizuda.easy.retry.client.core.annotation.Propagation; import com.aizuda.snailjob.client.core.annotation.Propagation;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Random; import java.util.Random;

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.handler; package com.example.snailjob.handler;
import com.aizuda.easy.retry.client.core.annotation.Propagation; import com.aizuda.snailjob.client.core.annotation.Propagation;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Random; import java.util.Random;

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.handler; package com.example.snailjob.handler;
import com.aizuda.easy.retry.client.core.annotation.Propagation; import com.aizuda.snailjob.client.core.annotation.Propagation;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Random; import java.util.Random;

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**

View File

@ -1,9 +1,9 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**

View File

@ -1,9 +1,9 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**

View File

@ -1,9 +1,9 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**

View File

@ -1,9 +1,9 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
/** /**
* @author zhengweilin * @author zhengweilin
@ -6,11 +6,11 @@ package com.example.easy.retry.job;
* @date 2024/01/22 * @date 2024/01/22
*/ */
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.example.easy.retry.po.FailOrderPo; import com.example.snailjob.po.FailOrderPo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Random; import java.util.Random;

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.job.core.executor.AbstractJobExecutor; import com.aizuda.snailjob.client.job.core.executor.AbstractJobExecutor;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
/** /**
* @author zhengweilin * @author zhengweilin
@ -6,10 +6,10 @@ package com.example.easy.retry.job;
* @date 2024/01/22 * @date 2024/01/22
*/ */
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.example.easy.retry.po.FailOrderPo; import com.example.snailjob.po.FailOrderPo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component

View File

@ -1,11 +1,11 @@
package com.example.easy.retry.job; package com.example.snailjob.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor; import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs; import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult; import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.easy.retry.common.log.EasyRetryLog; import com.aizuda.snailjob.common.log.SnailJobLog;
import com.example.easy.retry.po.FailOrderPo; import com.example.snailjob.po.FailOrderPo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@ -19,7 +19,7 @@ public class TestWorkflowAnnoJobExecutor {
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException { public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
// for (int i = 0; i < 30; i++) { // for (int i = 0; i < 30; i++) {
// EasyRetryLog.REMOTE.info("任务执行开始. [{}]", i + "" + JsonUtil.toJsonString(jobArgs)); // SnailJobLog.REMOTE.info("任务执行开始. [{}]", i + "" + JsonUtil.toJsonString(jobArgs));
// } // }
FailOrderPo failOrderPo = new FailOrderPo(); FailOrderPo failOrderPo = new FailOrderPo();
failOrderPo.setOrderId("xiaowoniu"); failOrderPo.setOrderId("xiaowoniu");

View File

@ -0,0 +1,19 @@
package com.example.snailjob.listener;
import com.aizuda.snailjob.client.common.event.SnailChannelReconnectEvent;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 21:58:18
* @since 3.1.0
*/
@Component
public class SnailJobChannelReconnectListener implements ApplicationListener<SnailChannelReconnectEvent> {
@Override
public void onApplicationEvent(SnailChannelReconnectEvent event) {
SnailJobLog.LOCAL.info("这个一个重连事件");
}
}

View File

@ -0,0 +1,19 @@
package com.example.snailjob.listener;
import com.aizuda.snailjob.client.common.event.SnailClientClosedEvent;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class SnailJobClosedListener implements ApplicationListener<SnailClientClosedEvent> {
@Override
public void onApplicationEvent(SnailClientClosedEvent event) {
SnailJobLog.LOCAL.info("这是一个SnailJob关闭完成事件");
}
}

View File

@ -0,0 +1,19 @@
package com.example.snailjob.listener;
import com.aizuda.snailjob.client.common.event.SnailClientClosingEvent;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class SnailJobClosingListener implements ApplicationListener<SnailClientClosingEvent> {
@Override
public void onApplicationEvent(SnailClientClosingEvent event) {
SnailJobLog.LOCAL.info("这是一个SnailJob开始关闭事件");
}
}

View File

@ -0,0 +1,19 @@
package com.example.snailjob.listener;
import com.aizuda.snailjob.client.common.event.SnailClientStartedEvent;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class SnailJobStartedListener implements ApplicationListener<SnailClientStartedEvent> {
@Override
public void onApplicationEvent(SnailClientStartedEvent event) {
SnailJobLog.LOCAL.info("这是一个SnailJob启动完成事件");
}
}

View File

@ -0,0 +1,19 @@
package com.example.snailjob.listener;
import com.aizuda.snailjob.client.common.event.SnailClientStartingEvent;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
* @author xiaowoniu
* @date 2024-03-14 22:00:58
* @since 3.1.0
*/
@Component
public class SnailJobStartingListener implements ApplicationListener<SnailClientStartingEvent> {
@Override
public void onApplicationEvent(SnailClientStartingEvent event) {
SnailJobLog.LOCAL.info("这是一个SnailJob启动事件");
}
}

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.po; package com.example.snailjob.po;
import java.time.LocalDateTime; import java.time.LocalDateTime;

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.service; package com.example.snailjob.service;
/** /**
* @author: www.byteblogs.com * @author: www.byteblogs.com

View File

@ -1,8 +1,8 @@
package com.example.easy.retry.service; package com.example.snailjob.service;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
/** /**
* @author: www.byteblogs.com * @author: www.byteblogs.com

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.service; package com.example.snailjob.service;
/** /**
* @author: www.byteblogs.com * @author: www.byteblogs.com

View File

@ -1,6 +1,6 @@
package com.example.easy.retry.service; package com.example.snailjob.service;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
/** /**
* @author: www.byteblogs.com * @author: www.byteblogs.com

View File

@ -1,9 +1,9 @@
package com.example.easy.retry.service.impl; package com.example.snailjob.service.impl;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.easy.retry.handler.LocalAndRemoteRetryHandler; import com.example.snailjob.handler.LocalAndRemoteRetryHandler;
import com.example.easy.retry.service.LocalRemoteService; import com.example.snailjob.service.LocalRemoteService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,19 +1,19 @@
package com.example.easy.retry.service.impl; package com.example.snailjob.service.impl;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.easy.retry.customized.OrderRetryMethod; import com.example.snailjob.customized.OrderRetryMethod;
import com.example.easy.retry.handler.OnlyLocalRetryHandler; import com.example.snailjob.handler.OnlyLocalRetryHandler;
import com.example.easy.retry.service.LocalRetryService; import com.example.snailjob.service.LocalRetryService;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
import com.example.snailjob.exception.ParamException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.example.easy.retry.exception.ParamException;
/** /**
* easy-retry中的本地重试demo * snail-job中的本地重试demo
*/ */
@Component @Component

View File

@ -1,15 +1,14 @@
package com.example.easy.retry.service.impl; package com.example.snailjob.service.impl;
import com.example.easy.retry.service.ManualRetryExecutorMethodService; import com.aizuda.snailjob.client.core.retryer.RetryTaskTemplateBuilder;
import com.aizuda.snailjob.client.core.retryer.SnailJobTemplate;
import com.example.snailjob.executor.ManualRetryExecutorTask;
import com.example.snailjob.service.ManualRetryExecutorMethodService;
import com.example.snailjob.vo.OrderVo;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.retryer.EasyRetryTemplate;
import com.aizuda.easy.retry.client.core.retryer.RetryTaskTemplateBuilder;
import com.example.easy.retry.executor.ManualRetryExecutorTask;
import com.example.easy.retry.vo.OrderVo;
/** /**
* easy-retry中的手动重试 * snail-job中的手动重试
*/ */
@Component @Component
public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutorMethodService { public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutorMethodService {
@ -19,7 +18,7 @@ public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutor
.orderId(params) .orderId(params)
.source(1) .source(1)
.build(); .build();
EasyRetryTemplate easyRetryTemplate = RetryTaskTemplateBuilder.newBuilder() SnailJobTemplate snailJobTemplate = RetryTaskTemplateBuilder.newBuilder()
// 手动指定场景名称 // 手动指定场景名称
.withScene(ManualRetryExecutorTask.SCENE) .withScene(ManualRetryExecutorTask.SCENE)
// 指定要执行的任务 // 指定要执行的任务
@ -28,7 +27,7 @@ public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutor
.withParam(orderVo) .withParam(orderVo)
.build(); .build();
// 执行模板 // 执行模板
easyRetryTemplate.executeRetry(); snailJobTemplate.executeRetry();
} }
} }

View File

@ -1,28 +1,27 @@
package com.example.easy.retry.service.impl; package com.example.snailjob.service.impl;
import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import com.aizuda.easy.retry.client.core.intercepter.RetrySiteSnapshot; import com.aizuda.snailjob.client.core.intercepter.RetrySiteSnapshot;
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum; import com.aizuda.snailjob.common.core.enums.RetryStatusEnum;
import com.example.easy.retry.handler.OnlyRemoteRetryHandler; import com.example.snailjob.handler.OnlyRemoteRetryHandler;
import com.example.easy.retry.service.RemoteRetryService; import com.example.snailjob.service.RemoteRetryService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.annotation.Retryable; import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType; import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.easy.retry.customized.MultiParamIdempotentGenerate; import com.example.snailjob.customized.MultiParamIdempotentGenerate;
import com.example.easy.retry.customized.OrderIdempotentIdGenerate; import com.example.snailjob.customized.OrderIdempotentIdGenerate;
import com.example.easy.retry.customized.OrderCompleteCallback; import com.example.snailjob.customized.OrderCompleteCallback;
import com.example.easy.retry.customized.OrderRetryMethod; import com.example.snailjob.customized.OrderRetryMethod;
import com.example.easy.retry.customized.SingleParamIdempotentGenerate; import com.example.snailjob.customized.SingleParamIdempotentGenerate;
import com.example.easy.retry.vo.OrderVo; import com.example.snailjob.vo.OrderVo;
/** /**
* easy-retry中的远程重试 * snail-job中的远程重试
*/ */
@Component @Component
@Slf4j @Slf4j

View File

@ -1,7 +1,7 @@
package com.example.easy.retry.spi; package com.example.snailjob.spi;
import com.aizuda.easy.retry.client.core.event.EasyRetryListener; import com.aizuda.snailjob.client.core.event.SnailJobListener;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.snailjob.common.core.util.JsonUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
* @date : 2023-08-28 11:20 * @date : 2023-08-28 11:20
*/ */
@Slf4j @Slf4j
public class MyEasyRetryListener implements EasyRetryListener { public class MySnailJobListener implements SnailJobListener {
@Override @Override
public void beforeRetry(final String sceneName, final String executorClassName, final Object[] params) { public void beforeRetry(final String sceneName, final String executorClassName, final Object[] params) {

View File

@ -1,6 +1,6 @@
package com.example.easy.retry.spi; package com.example.snailjob.spi;
import com.aizuda.easy.retry.client.core.RetrySiteSnapshotContext; import com.aizuda.snailjob.client.core.RetrySiteSnapshotContext;
import com.alibaba.ttl.TransmittableThreadLocal; import com.alibaba.ttl.TransmittableThreadLocal;
/** /**

View File

@ -1,6 +1,4 @@
package com.example.easy.retry.util; package com.example.snailjob.util;
import org.springframework.beans.factory.annotation.Value;
import com.baomidou.mybatisplus.generator.AutoGenerator; import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig; import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
@ -10,37 +8,37 @@ import com.baomidou.mybatisplus.generator.config.StrategyConfig;
public class CodeGen { public class CodeGen {
private static String dataSourceUrl = "jdbc:mysql://localhost:3306/easy_retry_260?useSSL=false&characterEncoding=utf8&useUnicode=true"; private static String dataSourceUrl = "jdbc:mysql://localhost:3306/snail_job_260?useSSL=false&characterEncoding=utf8&useUnicode=true";
private static String userName = "root"; private static String userName = "root";
private static String password= "root"; private static String password = "root";
public static void main(String[] args) { public static void main(String[] args) {
DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder(dataSourceUrl, userName, password).build(); DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder(dataSourceUrl, userName, password).build();
// 全局配置 // 全局配置
GlobalConfig globalConfig = new GlobalConfig.Builder() GlobalConfig globalConfig = new GlobalConfig.Builder()
.outputDir("src/main/java") .outputDir("src/main/java")
.author("xiaowoniu") .author("xiaowoniu")
.build(); .build();
// 策略配置 // 策略配置
StrategyConfig strategyConfig = new StrategyConfig.Builder() StrategyConfig strategyConfig = new StrategyConfig.Builder()
.addInclude("workflow") // 需要生成的表名 .addInclude("workflow") // 需要生成的表名
.build(); .build();
// 包配置 // 包配置
PackageConfig packageConfig = new PackageConfig.Builder() PackageConfig packageConfig = new PackageConfig.Builder()
.parent("com.aizuda.easy.retry.template.datasource.persistence.po") .parent("com.aizuda.snailjob.template.datasource.persistence.po")
.moduleName("easy-retry-springboot") .moduleName("snail-job-springboot")
.build(); .build();
// 代码生成器 // 代码生成器
AutoGenerator generator = new AutoGenerator(dataSourceConfig) AutoGenerator generator = new AutoGenerator(dataSourceConfig)
.global(globalConfig) .global(globalConfig)
.strategy(strategyConfig) .strategy(strategyConfig)
.packageInfo(packageConfig); .packageInfo(packageConfig);
// 执行生成代码 // 执行生成代码
generator.execute(); generator.execute();

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.vo; package com.example.snailjob.vo;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;

View File

@ -1,2 +0,0 @@
com.aizuda.easy.retry.client.core.expression.QLExpressEngine
#com.aizuda.easy.retry.client.core.expression.AviatorExpressionEngine

View File

@ -1 +0,0 @@
#com.aizuda.easy.retry.client.core.serializer.HessianSerializer

View File

@ -1 +0,0 @@
#com.example.easy.retry.spi.TTLRetrySiteSnapshotContext

View File

@ -1 +0,0 @@
#com.example.easy.retry.spi.MyEasyRetryListener

View File

@ -0,0 +1,2 @@
#com.aizuda.snailjob.client.core.expression.QLExpressEngine
#com.aizuda.snailjob.client.core.expression.AviatorExpressionEngine

View File

@ -0,0 +1 @@
#com.aizuda.snailjob.client.core.serializer.HessianSerializer

View File

@ -0,0 +1 @@
#spi.com.example.snail.job.TTLRetrySiteSnapshotContext

View File

@ -0,0 +1 @@
#spi.com.example.snail.job.MySnailJobListener

View File

@ -1,5 +1,6 @@
server: server:
port: 8018 port: 8018
spring: spring:
mvc: mvc:
pathmatch: pathmatch:
@ -7,8 +8,8 @@ spring:
profiles: profiles:
active: dev active: dev
datasource: datasource:
name: easy_retry name: snail_job
url: jdbc:mysql://localhost:3306/easy_retry_260?useSSL=false&characterEncoding=utf8&useUnicode=true url: jdbc:mysql://localhost:3306/snail_job_260?useSSL=false&characterEncoding=utf8&useUnicode=true
username: root username: root
password: root password: root
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
@ -22,9 +23,10 @@ spring:
pool-name: demo pool-name: demo
max-lifetime: 1800000 max-lifetime: 1800000
connection-test-query: SELECT 1 connection-test-query: SELECT 1
mybatis-plus: mybatis-plus:
mapper-locations: classpath:/mapper/*.xml mapper-locations: classpath:/mapper/*.xml
typeAliasesPackage: com.example.easy.retry.po typeAliasesPackage: com.example.snail.job.po
global-config: global-config:
db-config: db-config:
field-strategy: NOT_EMPTY field-strategy: NOT_EMPTY
@ -43,4 +45,4 @@ snail-job:
host: 127.0.0.1 host: 127.0.0.1
port: 1788 port: 1788
namespace: 764d604ec6fc45f68cd92514c40e9e1a namespace: 764d604ec6fc45f68cd92514c40e9e1a
token: ER_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj

View File

@ -1,6 +1,6 @@
<configuration> <configuration>
<property name="log.base" value="easy-retry-demo" /> <property name="log.base" value="snail-job-demo" />
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
@ -79,7 +79,7 @@
</appender> </appender>
<!-- Snail appender --> <!-- Snail appender -->
<appender name="snailLogAppender" class="com.aizuda.easy.retry.client.common.appender.SnailLogbackAppender"> <appender name="snailLogAppender" class="com.aizuda.snailjob.client.common.appender.SnailLogbackAppender">
</appender> </appender>
<!-- 控制台输出日志级别 --> <!-- 控制台输出日志级别 -->