定时任务消息 长时间未发送的进行清理
parent
8ba6d06eb5
commit
76ed8721a7
@ -0,0 +1,36 @@
|
|||||||
|
package com.hchbox.job;
|
||||||
|
|
||||||
|
import com.dangdang.ddframe.job.api.ShardingContext;
|
||||||
|
import com.dangdang.ddframe.job.api.simple.SimpleJob;
|
||||||
|
import com.example.autoconfig.ElasticSimpleJob;
|
||||||
|
import com.hchbox.module.service.TimerTaskService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjt
|
||||||
|
* @date 2021/11/26
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@ElasticSimpleJob(
|
||||||
|
jobName = "DeleteExpiredMessageJob", cron = "0 0 0/1 * * ?", shardingTotalCount = 1, overwrite = true, jobEvent = false)
|
||||||
|
@Component
|
||||||
|
public class DeleteExpiredMessageJob implements SimpleJob {
|
||||||
|
@Resource
|
||||||
|
private TimerTaskService timerTaskService;
|
||||||
|
|
||||||
|
private static DeleteExpiredMessageJob deleteExpiredMessageJob;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
deleteExpiredMessageJob = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(ShardingContext shardingContext) {
|
||||||
|
deleteExpiredMessageJob.timerTaskService.deleteNotSendMessage();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue