How to ensure that only one thread of EJB Timer Service executes

2k views Asked by At

I'm trying to convert my simple Quartz Job to an EJB Timer Service Job in JBOSS EAP 6.4.

I'm having an issue that I haven't been able to find a good answer for. I want to run this method once a day at 1 AM.

This is my class.

@Singleton
@Startup
public class JobExecutorService {

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

I'm getting these errors in the console:

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

What's the simplest way to prevent these threads from trying to spin up?

1

There are 1 answers

0
daniel9x On

I'm surprised no one answered this relatively easy question. The issue came down to an error in my @Schedule annotation. The method was attempting to be fired off for every second, hence the *. The correct method is:

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