【发布时间】:2016-12-10 14:37:17
【问题描述】:
我已经创建了一个函数doWork(),它被安排在每天凌晨1:00运行,函数如下:
@Schedule(hour = "1", persistent = false)
public void doWork()
{
System.out.println("Starting .....\nTIME: " + System.currentTimeMillis());
System.out.println("this : " + this);
//Some code here, if-conditions and try/catch blocks. No loops
System.out.println("Exiting .....\nTIME: " + System.currentTimeMillis());
System.out.println("this : " + this);
}
问题是这个函数运行了不止一次,没有按计划运行。
一旦我创建它,它就完全按照预期运行(每天凌晨 1:00:00)。几天后,它在 1:03:00 开始运行(这没有任何意义,因为它是非持久的,而且服务器也没有停机时间)。之后,该函数开始多次运行,其间的间隔非常短(秒差)
有谁知道这可能是什么原因,或者告诉我我能做些什么来解决它?
[编辑]: 环境细节
应用服务器:WebSphere Application Server 8.5.5
IDE:Rational Application Developer 9.1
数据库管理系统:IBM DB2 10.1
【问题讨论】:
-
您使用的是哪个应用服务器(和版本)?这可能有助于检查是否存在与该 AS 相关的问题。
-
您如何记录服务运行的时间?日志输出?系统/服务器时间?
-
@OlivierGrégoire 我正在使用 WebSphere Application Server 8.5.5
-
@kolossus 两次都是根据服务器时间记录的。该方法计划在凌晨 1:00 运行,但由于某种原因,它在随机时间运行,并且运行多次。
标签: jakarta-ee timer scheduling