3 Replies Latest reply on Oct 15, 2010 6:31 PM by Wayne Fuller

    Issue with Seam timer not firing

    Wayne Fuller Newbie

      We have created a timer with the following code to handle a basic job queue.  The job queue is database driven and is dependent on a Timer to check to see if any jobs are available.


      This is how the timers are created.


         @Observer( "org.jboss.seam.postInitialization" )
          public void initTheTimers() {
              Events.instance().raiseEvent( "jobs.flush" );
              Events.instance().raiseTimedEvent( "jobs.checkInvalid", new TimerSchedule( 0L, 5 * ONE_MINUTE ) );
              Events.instance().raiseTimedEvent( "jobs.check", new TimerSchedule( ONE_MINUTE, ONE_MINUTE / 2 ) );
          }



      And after one minute, this method gets called every 30 seconds.


         private static volatile boolean checkingForJobsCurrently = false;
      
          @Observer( { "jobs.check" } )
          @Asynchronous
          @Transactional( TransactionPropagationType.REQUIRED )
          public void checkForNodeJobs() {
              LOG.info( "Checking for new jobs..." );
              
              if ( !checkingForJobsCurrently ) {
                  checkingForJobsCurrently = true;
      
                  try {
                      //
                      // Assign jobs
                      //
                  } finally {
                      checkingForJobsCurrently = false;
                  }
              }
      
              LOG.info( "Finished checking for new jobs." );
          }
      



      If a user changes a particular item in our UI which requires what could be some complicated calculations, we create what we call a Job.  This job is then assigned a node to do the calculation.


      The problem is when we put ten or more jobs in the database, the timer stops firing every 30 seconds.  Sometimes it will not fire for 10 or longer minutes.  Once it does fire, then everything starts working.


      Is there a way to debug why a timer does not get fired?