Is it possible to get the date/time that the @Schedule expired?
If there is a delay in running the @Schedule, then the actual expired time is in the past. e.g. A persistant timer will run missed @Schedule when the server is restarted after a shutdown.
Example Job I tried.
import java.util.Date;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.Timer;
@Stateless
public class SimpleJob {
@Schedule(hour="*", minute = "*/1", second = "0", persistent = true) // Every 1 minute
public void schedule(Timer timer) {
System.out.println("Now: " + new Date());
System.out.println("\tTime remaining: "+ timer.getTimeRemaining());
System.out.println("\tNext Timeout: "+timer.getNextTimeout());
System.out.println("\tInfo: "+timer.getInfo());
}
}
When I restart the server after a shutdown I have missed the 10:34:00 and 10:35:00 @Schedule
Now: Wed Feb 04 10:35:05 EST 2015
Time remaining: 54235
Next Timeout: Wed Feb 04 10:36:00 EST 2015
Now: Wed Feb 04 10:35:05 EST 2015
Time remaining: 54233
Next Timeout: Wed Feb 04 10:36:00 EST 2015
Info: null
It correctly runs the missed @Schedule, but I cannot tell when each one was meant to run (which is important to my code).