1、修改定时任务超时时间

2、异常告警通知联系人邮箱
This commit is contained in:
SGK\17962 2025-06-08 00:21:36 +08:00
parent 9efe1597d3
commit 94bc7f4d78
7 changed files with 58 additions and 9 deletions

View File

@ -311,7 +311,8 @@ CREATE TABLE `sj_job`
`trigger_type` tinyint(4) NOT NULL COMMENT '触发类型 1.CRON 表达式 2. 固定时间',
`trigger_interval` varchar(255) NOT NULL COMMENT '间隔时长',
`block_strategy` tinyint(4) NOT NULL DEFAULT 1 COMMENT '阻塞策略 1、丢弃 2、覆盖 3、并行 4、恢复',
`executor_timeout` int(11) NOT NULL DEFAULT 0 COMMENT '任务执行超时时间,单位秒',
`executor_timeout_front` int(11) NOT NULL DEFAULT 60 COMMENT '(front)任务执行超时时间,单位秒',
`executor_timeout` int(11) NOT NULL DEFAULT 60 COMMENT '任务执行超时时间,单位秒',
`max_retry_times` int(11) NOT NULL DEFAULT 0 COMMENT '最大重试次数',
`parallel_num` int(11) NOT NULL DEFAULT 1 COMMENT '并行数',
`retry_interval` int(11) NOT NULL DEFAULT 0 COMMENT '重试间隔(s)',

View File

@ -102,6 +102,11 @@ public class Job extends CreateUpdateDt {
*/
private Integer executorTimeout;
/**
* 前端设置的任务执行超时时间单位秒
*/
private Integer executorTimeoutFront;
/**
* 最大重试次数
*/

View File

@ -50,6 +50,7 @@ import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.transaction.support.TransactionTemplate;
import scala.Int;
import java.text.MessageFormat;
import java.time.Duration;

View File

@ -4,6 +4,18 @@ server:
context-path: /snail-job
spring:
# mail:
# host: smtp.qq.com
# port: 465
# username: nianqing_16@qq.com
# password: yojeelyaxrvacihg
# protocol: smtp
# ssl:
# enable: true
# properties:
# mail.smtp.auth: true
# mail.smtp.starttls.enable: true
main:
banner-mode: off
profiles:
@ -82,3 +94,19 @@ snail-job:
server-port: 17888 # 服务器端口
log-storage: 7 # 日志保存时间(单位: day)
rpc-type: grpc
mail:
enabled: true
host: smtp.qq.com
port: 465
user: nianqing_16@qq.com
pass: yojeelyaxrvacihg
from: nianqing_16@qq.com
sslEnable: true
starttlsEnable: false
timeout: 5000
connectionTimeout: 5000
properties:
mail.smtp.auth: true
auth: true

View File

@ -85,6 +85,11 @@ public class JobResponseVO {
*/
private Integer executorTimeout;
/**
* 前置任务执行超时时间单位秒
*/
private Integer executorTimeoutFront;
/**
* 最大重试次数
*/

View File

@ -24,18 +24,24 @@ public interface JobConverter {
JobConverter INSTANCE = Mappers.getMapper(JobConverter.class);
@Mappings({
@Mapping(source = "executorTimeoutFront", target = "executorTimeout")
})
List<JobRequestVO> convertList(List<Job> jobs);
@Mappings({
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))")
})
JobRequestVO convert(Job job);
@Mappings({
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIdsStr(jobRequestVO.getNotifyIds()))")
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIdsStr(jobRequestVO.getNotifyIds()))"),
@Mapping(source = "executorTimeout", target = "executorTimeoutFront"),
@Mapping(target = "executorTimeout", expression = "java( (jobRequestVO.getExecutorTimeout() != null&&jobRequestVO.getExecutorTimeout() <= 0) ? Integer.MAX_VALUE : jobRequestVO.getExecutorTimeout())")
})
Job convert(JobRequestVO jobRequestVO);
@Mappings({
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))"),
@Mapping(source = "executorTimeoutFront", target = "executorTimeout")
})
JobRequestVO convert(Job job);
static Set<Long> toNotifyIds(String notifyIds) {
if (StrUtil.isBlank(notifyIds)) {
return new HashSet<>();
@ -51,4 +57,5 @@ public interface JobConverter {
return JsonUtil.toJsonString(notifyIds);
}
}

View File

@ -23,13 +23,15 @@ public interface JobResponseVOConverter {
JobResponseVOConverter INSTANCE = Mappers.getMapper(JobResponseVOConverter.class);
@Mappings({
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))")
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))"),
@Mapping(source = "executorTimeoutFront", target = "executorTimeout")
})
List<JobResponseVO> convertList(List<Job> jobs);
@Mappings({
@Mapping(target = "nextTriggerAt", expression = "java(JobResponseVOConverter.toLocalDateTime(job.getNextTriggerAt()))"),
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))")
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))"),
@Mapping(source = "executorTimeoutFront", target = "executorTimeout")
})
JobResponseVO convert(Job job);