Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

服务重启后,动态添加定时任务不会执行,如何解决 #2246

Open
houzhitongxue opened this issue Jul 28, 2023 · 3 comments
Open

Comments

@houzhitongxue
Copy link

/***
* 动态创建定时任务
* @param jobName:定时任务名称
* @param cron:表达式
* @param shardingTotalCount:分片数量
* @param instance:定时任务实例
* @param parameters:参数
*/
public void create(String jobName, String cron, int shardingTotalCount, SimpleJob instance, String parameters){
JobConfiguration jobConfig = JobConfiguration.newBuilder(jobName, shardingTotalCount)
.cron(cron)
.failover(true)
.overwrite(true)
.jobParameter(parameters)
.monitorExecution(true)
.misfire(true).build();

    //启动分布式定时任务
    new ScheduleJobBootstrap(registryCenter, new DynamicJob(), jobConfig).schedule();
}
@zhangconan
Copy link

应用重启之后,应用中就没有这些作业了。

@huaihuailj
Copy link

huaihuailj commented Apr 23, 2024 via email

@houzhitongxue
Copy link
Author

应用重启之后,应用中就没有这些作业了。

对,重启后需要重新加载定时任务

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants