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

fix(scheduler start error): change startScheduler method in Scheduler… #77

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/main/java/sast/evento/config/SchedulerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import lombok.extern.slf4j.Slf4j;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;
import sast.evento.common.enums.ErrorEnum;
import sast.evento.exception.LocalRunTimeException;
import sast.evento.utils.SchedulerUtil;

/**
* @Author: Love98
Expand All @@ -21,8 +20,7 @@ public class SchedulerConfig implements ApplicationListener<ContextRefreshedEven
public void onApplicationEvent(ContextRefreshedEvent event) {
try {
log.info("Start Scheduler");
SchedulerFactory schedulerFactoryBean = new StdSchedulerFactory();
schedulerFactoryBean.getScheduler().start();
SchedulerUtil.startScheduler();
} catch (SchedulerException e) {
throw new LocalRunTimeException(ErrorEnum.SCHEDULER_ERROR,"error start");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sast/evento/utils/SchedulerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ public static void shutdownScheduler() throws SchedulerException {

public static void startScheduler() throws SchedulerException {
Scheduler scheduler = getScheduler();
if (scheduler.isShutdown()) {
if (!scheduler.isStarted()) {
scheduler.start();
log.info("Scheduler start.");
} else {
log.info("Scheduler has start.");
log.warn("Scheduler has start.");
}
}

Expand Down