Как обеспечить выполнение только одного потока службы таймера EJB
Я пытаюсь преобразовать мою простую Кварцевую работу в Сервисную работу таймера EJB в JBOSS EAP 6.4.
У меня проблема, на которую я не смог найти хорошего ответа. Я хочу запускать этот метод один раз в день в 1 час ночи.
Это мой класс.
@Singleton
@Startup
public class JobExecutorService {
@Schedule(second = "*", minute = "*", hour = "1",persistent = false)
public void scheduleJobs() throws InterruptedException {
new ClinicalTrialsDataExtractor().execute();
}
}
Я получаю эти ошибки в консоли:
16:51:20,002 WARN [org.jboss.as.ejb3] (EJB default - 3) JBAS014143: A previous execution of timer [clinicalTrials.clinicalTrials.JobExecutorService ed420447-56b0-4d27-9533-f77e8a80ffbb] is still in progress, skipping this overlapping scheduled execution at: Tue Feb 23 16:51:20 EST 2016 as timer state is IN_TIMEOUT
16:51:21,004 WARN [org.jboss.as.ejb3] (EJB default - 4) JBAS014143: A previous execution of timer [clinicalTrials.clinicalTrials.JobExecutorService ed420447-56b0-4d27-9533-f77e8a80ffbb] is still in progress, skipping this overlapping scheduled execution at: Tue Feb 23 16:51:21 EST 2016 as timer state is IN_TIMEOUT
16:51:22,005 WARN [org.jboss.as.ejb3] (EJB default - 5) JBAS014143: A previous execution of timer [clinicalTrials.clinicalTrials.JobExecutorService ed420447-56b0-4d27-9533-f77e8a80ffbb] is still in progress, skipping this overlapping scheduled execution at: Tue Feb 23 16:51:22 EST 2016 as timer state is IN_TIMEOUT
16:51:23,004 WARN [org.jboss.as.ejb3] (EJB default - 6) JBAS014143: A previous execution of timer [clinicalTrials.clinicalTrials.JobExecutorService ed420447-56b0-4d27-9533-f77e8a80ffbb] is still in progress, skipping this overlapping scheduled execution at: Tue Feb 23 16:51:23 EST 2016 as timer state is IN_TIMEOUT
16:51:24,002 WARN [org.jboss.as.ejb3] (EJB default - 7) JBAS014143: A previous execution of timer [clinicalTrials.clinicalTrials.JobExecutorService ed420447-56b0-4d27-9533-f77e8a80ffbb] is still in progress, skipping this overlapping scheduled execution at: Tue Feb 23 16:51:24 EST 2016 as timer state is IN_TIMEOUT
Какой самый простой способ предотвратить появление этих потоков?
1 ответ
Я удивлен, что никто не ответил на этот относительно легкий вопрос. Проблема связана с ошибкой в моей аннотации @Schedule. Метод пытался срабатывать каждую секунду, поэтому *. Правильный метод:
@Schedule(second = "0", minute = "0", hour = "1",persistent = false)
public void scheduleJobs() throws InterruptedException {
new ClinicalTrialsDataExtractor().execute();
}