How do I create a non-persistent EJB 3.1 Timer?

强颜欢笑 提交于 2021-02-04 17:48:14

问题


Using NetBeans 7.1 / GlassFish 3.1, I created a new TimerSessionBean.

@Stateless
public class NewTimerSessionBean implements NewTimerSessionBeanLocal {

    @Schedule(minute = "*", second = "0", dayOfMonth = "*", month = "*", year = "*", hour = "9-17", dayOfWeek = "Mon-Fri")
        @Override
        public void myTimer() {
            System.out.println("Timer event: " + new Date());
        }
}

How can I declare that the timer is non-persistent? http://www.theserverside.com/news/1363578/EJB-31-A-Significant-Step-Towards-Maturity says there is a method isPersistent but it belongs to the Timer interface.

I came to this question after reading a description of potential problems with EJB timers in this article: http://www.coderanch.com/t/477104/EJB-JEE/java/Java-EE-timer-service-periodical


回答1:


According to this article you can achieve this by by adding persistent=false on @Schedule



来源:https://stackoverflow.com/questions/9078241/how-do-i-create-a-non-persistent-ejb-3-1-timer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!