Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 627
mjn Avatar asked Jan 31 '12 10:01

mjn


1 Answers

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

like image 66
Denis Tulskiy Avatar answered Oct 02 '22 19:10

Denis Tulskiy