好记性不如烂博客之 Quartz How-To: Update an existing job

接上一篇中 如果动态更新一个任务的计划(Trigger)http://www.cnblogs.com/daxin/archive/2013/05/30/3109296.html

这篇主要介绍的是如何动态替换一个任务,即动态的用 任务2 替换 任务1

 

        //SimpleJob新的任务类
        JobBuilder job1 = JobBuilder.newJob(SimpleJob.class);
        //与要替换的任务具有相同的name与group
        job1.withIdentity("name1", "group1");
        //这里一定设为true
        job1.storeDurably(true);
        JobDetail d2 = job1.build();
        
        //替换
        scheduler.addJob(d2, true);
 
 
// Add the new job to the scheduler, instructing it to "replace"
//  the existing job with the given name and group (if any)
JobDetail job1 = newJob(MyJobClass.class)
    .withIdentity("job1", "group1")
    .build();

// store, and set overwrite flag to 'true'     
scheduler.addJob(job1, true);

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值