10 Replies Latest reply on Nov 26, 2009 7:04 AM by jaikiran

    [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB Time

    longbeach

      Hi,
      As stated here : http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/EJBs_on_JBoss-EJB_Timer_Configuration.html


      Timer events are intended to be persistent and should be executed even in the event of a server failure.


      How do you disable persistence of EJB Timers in JBoss 5.1 GA, so that EJB timers do not automatically restart when the server restarts ?

      Thanks.

        • 1. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
          longbeach

          Well, after some investigation on the jmx console, it seems that one way to do it is to invoke the deleteTimer operation in the EJBTimerService service.

          Restart the server and the timer is gone.

          I am not sure this is the correct way to do it though.
          Can anyone confirm or infirm this ?

          Thanks

          • 2. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
            longbeach

            Correction :
            I meant to invoke the operation clearTimers and not deleteTimer

            Thanks.
            Celinio Fernandes

            • 3. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
              dimitris

              There is a NoopPersistencePolicy you can use in ejb3-timer-service.xml

              • 4. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                longbeach

                 

                "dimitris@jboss.org" wrote:
                There is a NoopPersistencePolicy you can use in ejb3-timer-service.xml


                Thanks.

                Did you mean jboss-5.1.0.GA.jdk6\server\default\deploy\ejb2-timer-service.xml ?

                Because i do not see any ejb3-timer-service.xml file in this version of JBoss.

                Celinio Fernandes

                • 5. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                  longbeach

                  There is also another file called ejb3-timerservice-jboss-beans.xml, which is almost empty.

                  Not too sure which one to use and tweak.

                  What do you think ?

                  Thanks
                  Celinio Fernandes

                  • 6. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                    wolfc

                    Dimitris meant ejb2-timer-service.xml, see also how it was done in AS 4 http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/EJBs_on_JBoss-EJB_Timer_Configuration.html.

                    ejb3-timerservice-jboss-beans.xml only defines a bean that delegates to the old EJB 2 Timer Service. So ejb2-timer-service.xml is authoritative.

                    • 7. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                      longbeach

                      Thanks wolfc.
                      So if i want to disable persistence of every timer, all i need to do is remove the comments around the EJBTimerService MBean, in ejb2-timer-service.xml :

                      <mbean code="org.jboss.ejb.txtimer.NoopPersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=noop"/>
                      


                      Am i correct ?

                      Thanks.
                      Celinio Fernandes

                      • 8. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                        jaikiran

                         

                        "longbeach" wrote:
                        all i need to do is remove the comments around the EJBTimerService MBean, in ejb2-timer-service.xml
                        ...
                        Am i correct ?



                        And also let the EJBTimerServiceImpl, in that file, know that it has to use this persistence policy. So change the PersistencePolicy attribute in that file to

                        <attribute name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=noop</attribute>
                        


                        • 9. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                          longbeach

                          Thanks.

                          So that means to change that code :

                           <!-- An EJB Timer Service that is Tx aware -->
                           <mbean code="org.jboss.ejb.txtimer.EJBTimerServiceImpl"
                           name="jboss.ejb:service=EJBTimerService">
                           <attribute name="TimerIdGeneratorClassName">org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator</attribute>
                           <attribute name="TimedObjectInvokerClassName">org.jboss.ejb.txtimer.TimedObjectInvokerImpl</attribute>
                           <depends optional-attribute-name="RetryPolicy">jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay</depends>
                           <depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=database</depends>
                           <depends optional-attribute-name="TransactionManagerFactory" proxy-type="org.jboss.tm.TransactionManagerFactory">
                           jboss:service=TransactionManager
                           </depends>
                           </mbean>
                          


                          to that :
                           <mbean code="org.jboss.ejb.txtimer.EJBTimerServiceImpl"
                           name="jboss.ejb:service=EJBTimerService">
                           <attribute name="TimerIdGeneratorClassName">org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator</attribute>
                           <attribute name="TimedObjectInvokerClassName">org.jboss.ejb.txtimer.TimedObjectInvokerImpl</attribute>
                           <attribute name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=noop</attribute>
                           <depends optional-attribute-name="RetryPolicy">jboss.ejb:service=EJBTimerService,retryPolicy=fixedDelay</depends>
                           <!-- <depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=database</depends> -->
                           <depends optional-attribute-name="TransactionManagerFactory" proxy-type="org.jboss.tm.TransactionManagerFactory">
                           jboss:service=TransactionManager
                           </depends>
                           </mbean>
                          
                          



                          I added that line and comment out the dependance on optional-attribute-name.

                          Is that right ? I am not too familiar with MBeans.

                          Thanks again.
                          Celinio Fernandes

                          • 10. Re: [JBoss 5.1 GA & EJB 3.0] disable persistence for an EJB
                            jaikiran

                             

                            "longbeach" wrote:

                            and comment out the dependance on optional-attribute-name.



                            Instead of commenting out that dependency, change it to depend on the new MBean:

                            <depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=noop</depends>