Authored by chaogeng

添加定时任务开关

... ... @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import com.netflix.config.DynamicLongProperty;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.activity.common.utils.PropertiesUtil;
import com.yoho.activity.queue.constant.Const;
import com.yoho.activity.queue.service.ITimeTaskService;
... ... @@ -21,21 +22,25 @@ public class LuckyUserNoticeThread {
private ITimeTaskService timeTaskService;
public LuckyUserNoticeThread(){
//(1)定时任务执行时间间隔,单位为分
DynamicLongProperty initialDelay = DynamicPropertyFactory.getInstance().getLongProperty("drawline.luckyUserNotice.interval", 120);
//(2)服务启动10后开始执行, 默认每隔2小时执行一次
Const.LUCKYUSERNOTICE_EXE.scheduleAtFixedRate(new Runnable() {
if(PropertiesUtil.getExecuteTask()){
//(1)定时任务执行时间间隔,单位为分
DynamicLongProperty initialDelay = DynamicPropertyFactory.getInstance().getLongProperty("drawline.luckyUserNotice.interval", 120);
@Override
public void run() {
logger.info("LuckyUserNotice thread start...");
//(2)服务启动10后开始执行, 默认每隔2小时执行一次
Const.LUCKYUSERNOTICE_EXE.scheduleAtFixedRate(new Runnable() {
timeTaskService.luckyUserNotice();
logger.info("LuckyUserNotice thread end.");
}
}, 10, initialDelay.get(), TimeUnit.MINUTES);
@Override
public void run() {
logger.info("LuckyUserNotice thread start...");
timeTaskService.luckyUserNotice();
logger.info("LuckyUserNotice thread end.");
}
}, 10, initialDelay.get(), TimeUnit.MINUTES);
}
}
}
... ...