6 Replies Latest reply on Feb 13, 2009 5:55 PM by leobaz2

    Prevent Persistence of EJB Timers

    leobaz2

      I am trying to prevent my EJB timers from being persisted across JBoss restarts by using the jboss.xml deployment descriptor. For some reason I can't seem to get this working. Was anyone able to specify the below in their jboss.xml and stop the timer persistence?


      <ejb-name>bean_name</ejb-name>
      <timer-persistence>false</timer-persistence>


      I would rather not have to change the mbean setting to NoopPersistencePolicy. Instead, I want to be able to turn off timer persistence from the EAR itself.

      Thanks.

        • 1. Re: Prevent Persistence of EJB Timers
          jaikiran

          Which version of JBossAS and is it EJB3 or EJB2.x? Also please post the exact contents including the dtd/xsd declaration of your jboss.xml.

          While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.

          • 2. Re: Prevent Persistence of EJB Timers
            leobaz2

            I am using EJB3 and JBoss 4.2.3. When dealing with EJB3, what is the name of the EJB? Is it the class name, the interface name, jndi name, or should I specify the name via annotations?

            <?xml version="1.0"?>
            
            <!DOCTYPE jboss PUBLIC
             "-//JBoss//DTD JBOSS 4.2//EN"
             "http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">
            
            <jboss>
             <enterprise-beans>
            
             <session>
             <ejb-name>ProductCacheUpdaterBean</ejb-name>
             <timer-persistence>false</timer-persistence>
             </session>
             <session>
             <ejb-name>CategoryCacheUpdaterBean</ejb-name>
             <timer-persistence>false</timer-persistence>
             </session>
            
             </enterprise-beans>
            </jboss>
            


            • 3. Re: Prevent Persistence of EJB Timers
              leobaz2

              This is the code that I have in the beans that are creating the timers.

              getSessionContext().getTimerService().createTimer(intervalDuration, intervalDuration, divisionKeys);

              The getSessionContext() is an inherited method from the base class that declares a private field:

              @Resource(name = "ses_context_ref")
              private SessionContext sessionContext;

              • 4. Re: Prevent Persistence of EJB Timers
                leobaz2

                I have tried every possible <ejb-name> but nothing seems to work. I have tried the bean impl class name, the interface name, and JNDI name. What else could it be?

                • 5. Re: Prevent Persistence of EJB Timers
                  wolfc

                  Non-persistent timers are not supported in the current EJB 3 implementation.

                  • 6. Re: Prevent Persistence of EJB Timers
                    leobaz2

                    I know they are not supported in the EJB 3.0 spec, however this is a JBoss extension since it's in the jboss.xml file. This is documented in the dtd for jboss.xml that comes with the installation and I have also seen it mentioned online.

                    One would think that since JBoss has it in the DTD, that it should work.