5 Replies Latest reply on Apr 12, 2012 12:20 PM by wdfink

    TimerService startup issue in JBoss AS 6

    arkhalil

      I am using JBoss AS 6. I have created a timer service listed bellow:

       

       

      package com.mycompany.infrastructure.notification.service;

       

      import javax.ejb.Schedule;

      import javax.ejb.Stateless;

      import javax.ejb.Timer;

       

      @Stateless

      public class NotificationTimerService {

       

          @Schedule(second = "*/30", minute = "*", hour = "*", dayOfWeek = "*", timezone = "GMT")

          public void executeSomeMethod(Timer timer) {

              System.out.println("Invoking daily event notification ...");

              / / call some session bean here

          }

      }

       

       

      Issues:

      1. When I restart jboss server the timer service starts execution before the conatainer/application is loaded completely. I want it start execution onces all the session beans (and other classes) are loaded.

      2. It executes all the previous invocations that were missed when jboss server was offline. I want it ignore missing calls due to offline mode.

       

      Thanks.

        • 1. Re: TimerService startup issue in JBoss AS 6
          wdfink

          You should inject the reference to other session beans via @EJB instead of lookup it,this should set a dependency.

           

          The @Schedule timer event is catch up all missing events if it is persistent (by default). If you don't want that behaviour you should set @Schedule(... persistent=false) this will avoid any catch up as long as the bean is down.

          • 2. Re: TimerService startup issue in JBoss AS 6
            arkhalil

            Thanks, This resolved the startup issue.

             

            1. About setting persistent=false, Will turning persistent off guaranty a single invocation at a particular interval in a clustered environment (multiple jboss instances)?

            2. I have also noticed receiving multiple invocations on single JVM at a specific interval. Can you guide about this too? Sorry for asking in the same thread.

            • 3. Re: TimerService startup issue in JBoss AS 6
              wdfink

              1.

              Nevertheless how persistence is set, the schedule is per instance. That mean if you deploy the application in a cluster with X nodes the bean is called X-times

              This is still the same as in former versions and still an issue (there are JIRA enhancements).

              A naive expectation is that it is a unique application event in a cluster, but it isn't the EJB spec does not specify the behaviour in a cluster.

               

              2.

              Can you explain a bit more, I don't understand what you meant ...

              • 4. Re: TimerService startup issue in JBoss AS 6
                arkhalil

                I mean the executeSomeMethod(Timer timer) is invoked multiple times after every 30 seconds. Thanks.

                • 5. Re: TimerService startup issue in JBoss AS 6
                  wdfink

                  Oh, ok

                  that smell like a solved bug (in AS7) with persistence=true.

                   

                  You should stop the server and remove all entries from the timers database or even drop the TIMERS tables.

                  1 of 1 people found this helpful