相关疑难解决方法(0)

在下次调用之前中断 spring 调度程序任务

我有一个 Spring-Boot 应用程序,它将成为我们想要触发的其他几个进程的编排服务。我目前使用 Spring Scheduling 从数据库中动态拉取 crons 进行了设置。我加入了一个 rest 方法来触发从数据库中提取新的 cron 信息的过程。这个逻辑一切正常。唯一的“问题”是它不使用新的 cron 信息,直到下一次计划运行才能解决真正的问题。 有没有办法中断当前的触发器并使用更新的 cron 信息再次安排一个。 以下是申请参考:

package com.bts.poc;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@SpringBootApplication
@EnableScheduling
@RestController
@RequestMapping("/APSCommon/Scheduling")
public class Application implements SchedulingConfigurer {

    @Autowired
    private DynamicCron dynamicCron;
    @Autowired
    PropertyManager propertyManager;

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class);
    }

    private String cronConfig() {
        String …
Run Code Online (Sandbox Code Playgroud)

java cron spring-scheduled spring-boot

4
推荐指数
1
解决办法
3711
查看次数

标签 统计

cron ×1

java ×1

spring-boot ×1

spring-scheduled ×1