I have a class annotated with @Singleton and a method annotated with @Schedule(hour = "*", minute = "*", second = "*/30", persistent = false). The task of this job is to run a check every 30 seconds. The problem is, that my Wildfly server runs this specific task twice within the same thread.
Here´s the log output of that specific case:
12:11:00,246 ERROR [com.service....] (EJB default - 10) ... (id: 6646)
12:11:00,496 ERROR [com.service....] (EJB default - 10) ... (id: 6644)
12:11:30,230 ERROR [com.service....] (EJB default - 1) ... (id: 6646)
12:11:30,464 ERROR [com.service....] (EJB default - 1) ... (id: 6644)
12:12:00,246 ERROR [com.service....] (EJB default - 4) ... (id: 6646)
12:12:00,464 ERROR [com.service....] (EJB default - 4) ... (id: 6644)
12:12:30,246 ERROR [com.service....] (EJB default - 6) ... (id: 6646)
12:12:30,465 ERROR [com.service....] (EJB default - 6) ... (id: 6644)
12:12:30,715 ERROR [com.service....] (EJB default - 6) ... (id: 6647)
As you can see on the timestamps, there are multiple jobs which run on the same thread.
Here is the code piece which is responsible for this job:
@Singleton
public class CustomScheduleService {
@Schedule(hour = "*", minute = "*", second = "*/30", persistent = false)
public void processPayments() {
doSomething();
}
}
My Wildfly instance does have two deployments of the same war file, and I´m aware, that this job might run once for each deployment. But after some digging in my logs, I found out that this output is only produced by one deployment instance.
How is this even possible, that the same thread runs two jobs mostly simultaneously and how do I resolve it?