2016-02-23 42 views
0

我試圖將我簡單的Quartz Job轉換爲JBOSS EAP 6.4中的EJB定時服務作業。如何確保只有一個EJB定時服務線程執行

我有一個問題,我一直沒能找到一個好的答案。我想在凌晨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 

什麼是防止這些線程試圖旋轉起來最簡單的方法是什麼?

回答

0

我很驚訝沒有人回答這個相對容易的問題。這個問題歸咎於我的@Schedule註釋中的一個錯誤。該方法試圖每秒被解僱,因此*。正確的方法是:

@Schedule(second = "0", minute = "0", hour = "1",persistent = false) 
public void scheduleJobs() throws InterruptedException { 
     new ClinicalTrialsDataExtractor().execute(); 
} 
相關問題