EJB 3.1 计时器在启动时执行,即使计划的时间不同

EJB 3.1 timer executes on startup even if the scheduled time is different

我使用 EJB 3.1 timee 和 schedulerd 创建了一个调度程序,在工作日的 22:30pm 执行。注释如下:

@Schedule(minute="30", hour="22", dayOfWeek="5–1")

但是我发现即使不是预定的时间,这个调度器在启动wildfly应用服务器后立即执行。

谢谢!

我不知道您的服务器何时重启的确切情况,但以防万一服务器在 22.20 关闭并在 22.35 启动,然后容器必须在重启后触发持久计时器的回调方法。正如规范所说 (18.4.3):

Any interval persistent timers or schedule based persistent timers that have expired during the intervening time must cause the corresponding timeout callback method to be invoked at least once upon restart.

您使用持久计时器,因此在计时器到期期间服务器重启可能是启动后立即执行回调的根本原因。