0 Replies Latest reply on Apr 30, 2008 1:21 PM by Thierry Rietsch

    Asyncronous method gets called only once

    Thierry Rietsch Newbie

      I try to implement an asynchronous method which gets initiated at startup.


      EJB with aynchronous method:


      @Stateless
      @Name("itemObserver")
      public class ItemObserverAction implements ItemObserver {
          @PersistenceContext
          private EntityManager em;
          
          @Logger
          private Log log;
              
          @Asynchronous
          public QuartzTriggerHandle observeItems(@IntervalDuration Long interval) {
           log.info("ItemObserver.observeItems at " + Calendar.getInstance().getTime());
                
           return null;
          }
      }



      The asynchronous method gets invoked for the first time during the startup of the application:



      @Stateless
      @Name("startupBootstrapAction")
      public class StartupBootstrapAction implements StartupBootstrap {
          @EJB
          private ItemObserver itemObserver;
          
          @Logger
          private Log log;
          
          @Observer("org.jboss.seam.postInitialization")
          public void startApplication() {
           log.info("StartupBootstrapAction.startApplication called");
           itemObserver.observeItems(new Long(5000));
          }
      }



      In the components.xml i have added the async:quartz-dispatcher
      entry.


      When the application runs on JBoss the quartz scheduler gets started, and the observeItem method gets called once. But unfortunately only once.


      Output of the JBoss server during deploy and startup of the ear:



      13:04:47,603 INFO  [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
      13:04:47,605 INFO  [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
      13:04:47,605 INFO  [StdSchedulerFactory] Quartz scheduler version: 1.5.2
      13:04:47,605 INFO  [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
      13:04:47,620 INFO  [StartupBootstrapAction] StartupBootstrapAction.startApplication called
      13:04:47,628 INFO  [ItemObserverAction] ItemObserver.observeItems at Wed Apr 30 13:04:47 CEST 2008



      But if I continue observing the logfile, I don't see any further log entries from the ItemObserver.observeItems method. Do I have to configure something else that I get an asynchronous job up and running?