中断长时间运行的javax.ejb.TimerService作业

时间:2013-04-11 07:07:52

标签: java-ee

我正在使用Java EE 6 TimerService来执行长时间运行的任务(大约30分钟)。这个任务很容易被中断,因为它的业务逻辑能够每5秒钟取消一次。

现在的问题是如何在执行的方法中获取取消部署应用程序的事件,这样我就可以在Java EE容器中重新部署和取消部署时取消执行。

示例:

@Singleton
public class AnyClass {

    @Schedule(hour = "9", minute="17")
    public void service() {
        for(i = 1000; i < 1000; i++) {
            doSomethingForAbout5Seconds();
            // here I want to cancel the execution in 
            // case of undeployment of the apllication
        }
    }
}   

0 个答案:

没有答案
相关问题