1、修改定时任务超时时间
2、异常告警通知联系人邮箱
This commit is contained in:
parent
9efe1597d3
commit
94bc7f4d78
@ -311,7 +311,8 @@ CREATE TABLE `sj_job`
|
|||||||
`trigger_type` tinyint(4) NOT NULL COMMENT '触发类型 1.CRON 表达式 2. 固定时间',
|
`trigger_type` tinyint(4) NOT NULL COMMENT '触发类型 1.CRON 表达式 2. 固定时间',
|
||||||
`trigger_interval` varchar(255) NOT NULL COMMENT '间隔时长',
|
`trigger_interval` varchar(255) NOT NULL COMMENT '间隔时长',
|
||||||
`block_strategy` tinyint(4) NOT NULL DEFAULT 1 COMMENT '阻塞策略 1、丢弃 2、覆盖 3、并行 4、恢复',
|
`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 '最大重试次数',
|
`max_retry_times` int(11) NOT NULL DEFAULT 0 COMMENT '最大重试次数',
|
||||||
`parallel_num` int(11) NOT NULL DEFAULT 1 COMMENT '并行数',
|
`parallel_num` int(11) NOT NULL DEFAULT 1 COMMENT '并行数',
|
||||||
`retry_interval` int(11) NOT NULL DEFAULT 0 COMMENT '重试间隔(s)',
|
`retry_interval` int(11) NOT NULL DEFAULT 0 COMMENT '重试间隔(s)',
|
||||||
|
@ -102,6 +102,11 @@ public class Job extends CreateUpdateDt {
|
|||||||
*/
|
*/
|
||||||
private Integer executorTimeout;
|
private Integer executorTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前端设置的任务执行超时时间,单位秒
|
||||||
|
*/
|
||||||
|
private Integer executorTimeoutFront;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最大重试次数
|
* 最大重试次数
|
||||||
*/
|
*/
|
||||||
|
@ -50,6 +50,7 @@ import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
|||||||
import org.springframework.transaction.support.TransactionSynchronization;
|
import org.springframework.transaction.support.TransactionSynchronization;
|
||||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
import scala.Int;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -4,6 +4,18 @@ server:
|
|||||||
context-path: /snail-job
|
context-path: /snail-job
|
||||||
|
|
||||||
spring:
|
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:
|
main:
|
||||||
banner-mode: off
|
banner-mode: off
|
||||||
profiles:
|
profiles:
|
||||||
@ -82,3 +94,19 @@ snail-job:
|
|||||||
server-port: 17888 # 服务器端口
|
server-port: 17888 # 服务器端口
|
||||||
log-storage: 7 # 日志保存时间(单位: day)
|
log-storage: 7 # 日志保存时间(单位: day)
|
||||||
rpc-type: grpc
|
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
|
||||||
|
|
||||||
|
@ -85,6 +85,11 @@ public class JobResponseVO {
|
|||||||
*/
|
*/
|
||||||
private Integer executorTimeout;
|
private Integer executorTimeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前置任务执行超时时间,单位秒
|
||||||
|
*/
|
||||||
|
private Integer executorTimeoutFront;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最大重试次数
|
* 最大重试次数
|
||||||
*/
|
*/
|
||||||
|
@ -24,18 +24,24 @@ public interface JobConverter {
|
|||||||
|
|
||||||
JobConverter INSTANCE = Mappers.getMapper(JobConverter.class);
|
JobConverter INSTANCE = Mappers.getMapper(JobConverter.class);
|
||||||
|
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(source = "executorTimeoutFront", target = "executorTimeout")
|
||||||
|
})
|
||||||
List<JobRequestVO> convertList(List<Job> jobs);
|
List<JobRequestVO> convertList(List<Job> jobs);
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIds(job.getNotifyIds()))")
|
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIdsStr(jobRequestVO.getNotifyIds()))"),
|
||||||
})
|
@Mapping(source = "executorTimeout", target = "executorTimeoutFront"),
|
||||||
JobRequestVO convert(Job job);
|
@Mapping(target = "executorTimeout", expression = "java( (jobRequestVO.getExecutorTimeout() != null&&jobRequestVO.getExecutorTimeout() <= 0) ? Integer.MAX_VALUE : jobRequestVO.getExecutorTimeout())")
|
||||||
|
|
||||||
@Mappings({
|
|
||||||
@Mapping(target = "notifyIds", expression = "java(JobConverter.toNotifyIdsStr(jobRequestVO.getNotifyIds()))")
|
|
||||||
})
|
})
|
||||||
Job convert(JobRequestVO jobRequestVO);
|
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) {
|
static Set<Long> toNotifyIds(String notifyIds) {
|
||||||
if (StrUtil.isBlank(notifyIds)) {
|
if (StrUtil.isBlank(notifyIds)) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
@ -51,4 +57,5 @@ public interface JobConverter {
|
|||||||
|
|
||||||
return JsonUtil.toJsonString(notifyIds);
|
return JsonUtil.toJsonString(notifyIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,15 @@ public interface JobResponseVOConverter {
|
|||||||
JobResponseVOConverter INSTANCE = Mappers.getMapper(JobResponseVOConverter.class);
|
JobResponseVOConverter INSTANCE = Mappers.getMapper(JobResponseVOConverter.class);
|
||||||
|
|
||||||
@Mappings({
|
@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);
|
List<JobResponseVO> convertList(List<Job> jobs);
|
||||||
|
|
||||||
@Mappings({
|
@Mappings({
|
||||||
@Mapping(target = "nextTriggerAt", expression = "java(JobResponseVOConverter.toLocalDateTime(job.getNextTriggerAt()))"),
|
@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);
|
JobResponseVO convert(Job job);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user