Merge branch 'refs/heads/snail_job_1.0.0'

This commit is contained in:
byteblogs168 2024-05-15 23:35:39 +08:00
commit 7a41654168
65 changed files with 368 additions and 383 deletions

2
.gitignore vendored
View File

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

19
pom.xml
View File

@ -43,23 +43,18 @@
</dependency>
<dependency>
<groupId>com.aizuda</groupId>
<artifactId>easy-retry-client-starter</artifactId>
<version>3.2.0</version>
<artifactId>snail-job-client-starter</artifactId>
<version>1.0.0-beta1</version>
</dependency>
<dependency>
<groupId>com.aizuda</groupId>
<artifactId>easy-retry-client-core</artifactId>
<version>3.2.0</version>
<artifactId>snail-job-client-retry-core</artifactId>
<version>1.0.0-beta1</version>
</dependency>
<dependency>
<groupId>com.aizuda</groupId>
<artifactId>easy-retry-client-job-core</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
<artifactId>snail-job-client-job-core</artifactId>
<version>1.0.0-beta1</version>
</dependency>
<dependency>
<groupId>com.googlecode.aviator</groupId>
@ -119,7 +114,7 @@
</dependencies>
<build>
<finalName>easy-retry-example</finalName>
<finalName>snail-job-example</finalName>
<plugins>
<plugin>
<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,29 +0,0 @@
package com.example.easy.retry.job;
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor;
import com.aizuda.easy.retry.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.easy.retry.common.log.EasyRetryLog;
import com.example.easy.retry.po.FailOrderPo;
import org.springframework.stereotype.Component;
/**
* @author www.byteblogs.com
* @date 2023-09-28 22:54:07
* @since 2.6.0
*/
@Component
@JobExecutor(name = "testWorkflowAnnoJobExecutor")
public class TestWorkflowAnnoJobExecutor {
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
for (int i = 0; i < 30; i++) {
EasyRetryLog.REMOTE.info("任务执行开始. [{}]", i + "" + JsonUtil.toJsonString(jobArgs));
}
FailOrderPo failOrderPo = new FailOrderPo();
failOrderPo.setOrderId("xiaowoniu");
return ExecuteResult.success(failOrderPo);
}
}

View File

@ -1,19 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.ChannelReconnectEvent;
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<ChannelReconnectEvent> {
@Override
public void onApplicationEvent(ChannelReconnectEvent event) {
EasyRetryLog.LOCAL.info("这个一个重连事件");
}
}

View File

@ -1,20 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.EasyRetryClosedEvent;
import com.aizuda.easy.retry.client.common.event.EasyRetryStartedEvent;
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<EasyRetryClosedEvent> {
@Override
public void onApplicationEvent(EasyRetryClosedEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry关闭完成事件");
}
}

View File

@ -1,20 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.EasyRetryClosingEvent;
import com.aizuda.easy.retry.client.common.event.EasyRetryStartedEvent;
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<EasyRetryClosingEvent> {
@Override
public void onApplicationEvent(EasyRetryClosingEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry开始关闭事件");
}
}

View File

@ -1,20 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.EasyRetryStartedEvent;
import com.aizuda.easy.retry.client.common.event.EasyRetryStartingEvent;
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<EasyRetryStartedEvent> {
@Override
public void onApplicationEvent(EasyRetryStartedEvent event) {
EasyRetryLog.LOCAL.info("这是一个EasyRetry启动完成事件");
}
}

View File

@ -1,20 +0,0 @@
package com.example.easy.retry.listener;
import com.aizuda.easy.retry.client.common.event.ChannelReconnectEvent;
import com.aizuda.easy.retry.client.common.event.EasyRetryStartingEvent;
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<EasyRetryStartingEvent> {
@Override
public void onApplicationEvent(EasyRetryStartingEvent 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.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -8,13 +8,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.TimeZone;
@SpringBootApplication
@EnableEasyRetry(group = "easy_retry_demo_group")
@MapperScan("com.example.easy.retry.dao")
public class EasyRetrySpringbootApplication {
@EnableSnailJob(group = "snail_job_demo_group")
@MapperScan("com.example.snailjob.dao")
public class SnailJobSpringbootApplication {
public static void main(String[] args) {
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.snailjob.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.Parameter;
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.Parameter;
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.RestController;
import com.example.easy.retry.service.LocalRetryService;
import com.example.snailjob.service.LocalRetryService;
@RestController
@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.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.RestController;
import com.example.easy.retry.service.ManualRetryExecutorMethodService;
import com.example.snailjob.service.ManualRetryExecutorMethodService;
@RestController
@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.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.RestController;
import com.example.easy.retry.vo.OrderVo;
import com.example.easy.retry.service.RemoteRetryService;
import com.example.snailjob.vo.OrderVo;
import com.example.snailjob.service.RemoteRetryService;
@RestController
@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 lombok.extern.slf4j.Slf4j;
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.easy.retry.common.core.model.IdempotentIdContext;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
import com.example.snailjob.vo.OrderVo;
import cn.hutool.crypto.SecureUtil;
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 com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.snailjob.client.core.callback.RetryCompleteCallback;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.example.easy.retry.dao.FailOrderBaseMapper;
import com.example.easy.retry.po.FailOrderPo;
import com.example.easy.retry.vo.OrderVo;
import com.example.snailjob.dao.FailOrderBaseMapper;
import com.example.snailjob.po.FailOrderPo;
import com.example.snailjob.vo.OrderVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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.easy.retry.client.core.IdempotentIdGenerate;
import com.aizuda.easy.retry.common.core.model.IdempotentIdContext;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
import com.example.snailjob.vo.OrderVo;
import cn.hutool.crypto.SecureUtil;

View File

@ -1,11 +1,9 @@
package com.example.easy.retry.customized;
import java.lang.reflect.Array;
package com.example.snailjob.customized;
import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.strategy.ExecutorMethod;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.strategy.ExecutorMethod;
import com.example.snailjob.vo.OrderVo;
import cn.hutool.json.JSONUtil;
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.easy.retry.common.core.model.IdempotentIdContext;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.IdempotentIdGenerate;
import com.aizuda.snailjob.common.core.model.IdempotentIdContext;
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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.easy.retry.po.FailOrderPo;
import com.example.snailjob.po.FailOrderPo;
@Repository
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.easy.retry.client.core.strategy.ExecutorMethod;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.annotation.ExecutorMethodRegister;
import com.aizuda.snailjob.client.core.strategy.ExecutorMethod;
import com.example.snailjob.vo.OrderVo;
import cn.hutool.json.JSONUtil;
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.easy.retry.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType;
import com.aizuda.snailjob.client.core.annotation.Propagation;
import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import org.springframework.stereotype.Component;
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.easy.retry.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType;
import com.aizuda.snailjob.client.core.annotation.Propagation;
import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import org.springframework.stereotype.Component;
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.easy.retry.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType;
import com.aizuda.snailjob.client.core.annotation.Propagation;
import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import org.springframework.stereotype.Component;
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.easy.retry.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
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.easy.retry.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
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.easy.retry.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
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.easy.retry.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
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.easy.retry.client.job.core.dto.JobArgs;
import com.aizuda.easy.retry.client.model.ExecuteResult;
import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

View File

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

View File

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

View File

@ -0,0 +1,29 @@
package com.example.snailjob.job;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import com.example.snailjob.po.FailOrderPo;
import org.springframework.stereotype.Component;
/**
* @author www.byteblogs.com
* @date 2023-09-28 22:54:07
* @since 2.6.0
*/
@Component
@JobExecutor(name = "testWorkflowAnnoJobExecutor")
public class TestWorkflowAnnoJobExecutor {
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
// for (int i = 0; i < 30; i++) {
// SnailJobLog.REMOTE.info("任务执行开始. [{}]", i + "" + JsonUtil.toJsonString(jobArgs));
// }
FailOrderPo failOrderPo = new FailOrderPo();
failOrderPo.setOrderId("xiaowoniu");
return ExecuteResult.success(failOrderPo);
}
}

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;

View File

@ -1,4 +1,4 @@
package com.example.easy.retry.service;
package com.example.snailjob.service;
/**
* @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.easy.retry.client.core.retryer.RetryType;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.snailjob.vo.OrderVo;
/**
* @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

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

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.easy.retry.client.core.retryer.RetryType;
import com.example.easy.retry.handler.LocalAndRemoteRetryHandler;
import com.example.easy.retry.service.LocalRemoteService;
import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.snailjob.handler.LocalAndRemoteRetryHandler;
import com.example.snailjob.service.LocalRemoteService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.example.easy.retry.customized.OrderRetryMethod;
import com.example.easy.retry.handler.OnlyLocalRetryHandler;
import com.example.easy.retry.service.LocalRetryService;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.snailjob.customized.OrderRetryMethod;
import com.example.snailjob.handler.OnlyLocalRetryHandler;
import com.example.snailjob.service.LocalRetryService;
import com.example.snailjob.vo.OrderVo;
import com.example.snailjob.exception.ParamException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.annotation.Retryable;
import com.example.easy.retry.exception.ParamException;
import com.aizuda.snailjob.client.core.annotation.Retryable;
/**
* easy-retry中的本地重试demo
* snail-job中的本地重试demo
*/
@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 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
public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutorMethodService {
@ -19,7 +18,7 @@ public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutor
.orderId(params)
.source(1)
.build();
EasyRetryTemplate easyRetryTemplate = RetryTaskTemplateBuilder.newBuilder()
SnailJobTemplate snailJobTemplate = RetryTaskTemplateBuilder.newBuilder()
// 手动指定场景名称
.withScene(ManualRetryExecutorTask.SCENE)
// 指定要执行的任务
@ -28,7 +27,7 @@ public class ManualRetryExecutorMethodServiceImpl implements ManualRetryExecutor
.withParam(orderVo)
.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 cn.hutool.core.lang.Assert;
import com.aizuda.easy.retry.client.core.intercepter.RetrySiteSnapshot;
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
import com.example.easy.retry.handler.OnlyRemoteRetryHandler;
import com.example.easy.retry.service.RemoteRetryService;
import com.aizuda.snailjob.client.core.intercepter.RetrySiteSnapshot;
import com.aizuda.snailjob.common.core.enums.RetryStatusEnum;
import com.example.snailjob.handler.OnlyRemoteRetryHandler;
import com.example.snailjob.service.RemoteRetryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import com.aizuda.easy.retry.client.core.annotation.Retryable;
import com.aizuda.easy.retry.client.core.retryer.RetryType;
import com.example.easy.retry.customized.MultiParamIdempotentGenerate;
import com.example.easy.retry.customized.OrderIdempotentIdGenerate;
import com.example.easy.retry.customized.OrderCompleteCallback;
import com.example.easy.retry.customized.OrderRetryMethod;
import com.example.easy.retry.customized.SingleParamIdempotentGenerate;
import com.example.easy.retry.vo.OrderVo;
import com.aizuda.snailjob.client.core.annotation.Retryable;
import com.aizuda.snailjob.client.core.retryer.RetryType;
import com.example.snailjob.customized.MultiParamIdempotentGenerate;
import com.example.snailjob.customized.OrderIdempotentIdGenerate;
import com.example.snailjob.customized.OrderCompleteCallback;
import com.example.snailjob.customized.OrderRetryMethod;
import com.example.snailjob.customized.SingleParamIdempotentGenerate;
import com.example.snailjob.vo.OrderVo;
/**
* easy-retry中的远程重试
* snail-job中的远程重试
*/
@Component
@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.easy.retry.common.core.util.JsonUtil;
import com.aizuda.snailjob.client.core.event.SnailJobListener;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
/**
@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j;
* @date : 2023-08-28 11:20
*/
@Slf4j
public class MyEasyRetryListener implements EasyRetryListener {
public class MySnailJobListener implements SnailJobListener {
@Override
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;
/**

View File

@ -1,6 +1,4 @@
package com.example.easy.retry.util;
import org.springframework.beans.factory.annotation.Value;
package com.example.snailjob.util;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
@ -10,37 +8,37 @@ import com.baomidou.mybatisplus.generator.config.StrategyConfig;
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 password= "root";
private static String password = "root";
public static void main(String[] args) {
DataSourceConfig dataSourceConfig = new DataSourceConfig.Builder(dataSourceUrl, userName, password).build();
// 全局配置
GlobalConfig globalConfig = new GlobalConfig.Builder()
.outputDir("src/main/java")
.author("xiaowoniu")
.build();
.outputDir("src/main/java")
.author("xiaowoniu")
.build();
// 策略配置
StrategyConfig strategyConfig = new StrategyConfig.Builder()
.addInclude("workflow") // 需要生成的表名
.build();
.addInclude("workflow") // 需要生成的表名
.build();
// 包配置
PackageConfig packageConfig = new PackageConfig.Builder()
.parent("com.aizuda.easy.retry.template.datasource.persistence.po")
.moduleName("easy-retry-springboot")
.build();
.parent("com.aizuda.snailjob.template.datasource.persistence.po")
.moduleName("snail-job-springboot")
.build();
// 代码生成器
AutoGenerator generator = new AutoGenerator(dataSourceConfig)
.global(globalConfig)
.strategy(strategyConfig)
.packageInfo(packageConfig);
.global(globalConfig)
.strategy(strategyConfig)
.packageInfo(packageConfig);
// 执行生成代码
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.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:
port: 8018
spring:
mvc:
pathmatch:
@ -7,8 +8,8 @@ spring:
profiles:
active: dev
datasource:
name: easy_retry
url: jdbc:mysql://localhost:3306/easy_retry_260?useSSL=false&characterEncoding=utf8&useUnicode=true
name: snail_job
url: jdbc:mysql://localhost:3306/snail_job_260?useSSL=false&characterEncoding=utf8&useUnicode=true
username: root
password: root
type: com.zaxxer.hikari.HikariDataSource
@ -22,9 +23,10 @@ spring:
pool-name: demo
max-lifetime: 1800000
connection-test-query: SELECT 1
mybatis-plus:
mapper-locations: classpath:/mapper/*.xml
typeAliasesPackage: com.example.easy.retry.po
typeAliasesPackage: com.example.snail.job.po
global-config:
db-config:
field-strategy: NOT_EMPTY
@ -38,9 +40,9 @@ mybatis-plus:
logging:
config: classpath:logback-boot.xml
easy-retry:
snail-job:
server:
host: 127.0.0.1
port: 1788
namespace: 764d604ec6fc45f68cd92514c40e9e1a
token: ER_cKqBTPzCsWA3VyuCfFoccmuIEGXjr5KT
token: SJ_Wyz3dmsdbDOkDujOTSSoBjGQP1BMsVnj

View File

@ -1,6 +1,6 @@
<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">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
@ -78,8 +78,8 @@
<appender-ref ref ="fileError"/>
</appender>
<!-- EasyRetry appender -->
<appender name="easyLogAppender" class="com.aizuda.easy.retry.client.common.appender.EasyRetryLogbackAppender">
<!-- Snail appender -->
<appender name="snailLogAppender" class="com.aizuda.snailjob.client.common.appender.SnailLogbackAppender">
</appender>
<!-- 控制台输出日志级别 -->
@ -88,6 +88,6 @@
<appender-ref ref="asyncInfo" />
<appender-ref ref="asyncWarn" />
<appender-ref ref="asyncError" />
<appender-ref ref="easyLogAppender" />
<appender-ref ref="snailLogAppender" />
</root>
</configuration>