我想知道Ejb定时器服务如何计算超时?它是否需要系统时间并根据它计算超时,或者它内部是否具有为自己运行计时器的机制。如果它使用自己的机制,它是什么?我们可以进行一些设置,以便它可以根据系统时间计算超时吗?
我已经搜索了此信息,但没有找到任何相关信息。我目前在代码中使用 TimerService 并以编程方式创建计时器。但是当我更改系统时间时,计时器确实会按此工作。在创建计时器时的步进时间之后发生超时。
如果我不更改系统时间,那么调度程序就可以正常工作..
即使你可以将我重定向到任何此类信息,这将是 gr8 帮助。
任何帮助都会非常感激。
代码是这样的
ScheduleExpression everyDayAtTenTwenty = new ScheduleExpression();
TimerConfig timerConfig = new TimerConfig();
timerConfig.setPersistent(false);
timerConfig.setInfo("testTask");
everyDayAtTenTwenty.start(date).year("2011,2012").month("Jun").dayOfMonth("19").dayOfWeek("*").hour("16-23").minute("30"); timerConfig.setInfo("testTask : ");
timerKeeperBeanLocal.scheduleTimer(everyDayAtTenTwenty, timerConfig);
timerKeeperBeanLocal implementation
@Resource
private TimerService timerService;
Timer timer = this.timerService.createCalendarTimer(scheduleExpression, timerConfig);
<小时/>
现在我希望调度程序在 2011 年 6 月 19 日和 2012 年执行。现在当前日期是 2011 年 6 月 19 日,所以今天它执行,同一天我将系统日期更改为 2011 年 6 月 29 日以及适当的时间。在这种情况下,调度程序不起作用。可以用几个小时的变化来测试同样的情况。 我需要做其他事情才能按照系统时间工作吗?
提前致谢。
最佳答案
Ejb 计时器服务使用 Java SE 时间 API,而 Java SE 时间 API 又基于系统时间。参见
http://download.oracle.com/javase/6/docs/api/java/util/Date.html
这是 EJB 3.1 规范的引用:
While timer durations are expressed in millisecond units, this is because the millisecond is the unit of time granularity used by the APIs of the Java SE platform.
关于java - ejb 3.1定时器服务如何计算超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8009031/