4 Replies Latest reply on Feb 8, 2008 8:13 AM by Patrick Stahmer

    Schedule Reports to Run Daily at Certain Time

    Dave Everson Newbie

      We have a requirement to produce daily reports that are always ran at the same time of the day. These reports are run in a "batch" mode.

      Within our Seam application, users can also schedule their own reports to run based on their preference.

      To meet the second requirement, we have configured our Seam 2.0.1CR1 application to use Quartz, persisting cron expressions and report values in the database based on the user's preferences. This is working fine.

      Our challenge is in meeting the first requirement (batch/non-user specific reports).

      We have followed the suggestions found in http://in.relation.to/Bloggers/DoingSomethingAtStartupWithSeam to schedule a Quartz job at startup. This works fine the first time that JBoss is restarted. However, each additional time that JBoss is restarted a new job is added to the database.

      Is there any easy way of addressing this requirement in Seam? I was thinking that the "batch"/non-user specific reports could be schedule in memory in Quartz so that the schedule is not maintained across restarts.

      Another option would be for me to manually add the job to the database (via a SQL script). However I don't know the format of some of the serialized blobs.

      Any suggestions on how we could realize our requirements using Seam/Quartz?

      Environment: JBoss 4.2, Seam 2.0.1CR1, Quartz 1.6, MySQL 5

        • 2. Re: Schedule Reports to Run Daily at Certain Time
          Elvis D, Novice

          don't if can help you, i have configured a user service to run every day at 8:00 AM.
          you should implement a schedulable class and define the scheduler in scheduler-service.xml.
          Your schedulable class then is called in the given interval.

          I have used this link to learn how to do it... (sorry it s in french)

          To run a task every day at given period just adapt the scheduler config with values as:

           <attribute name="StartAtStartup">true</attribute>
           <attribute name="SchedulableClass">org.pagckage.MyClass</attribute>
           <attribute name="SchedulableArguments">500</attribute>
           <attribute name="SchedulableArgumentTypes">double</attribute>
           <attribute name="FixedRate">true</attribute>
           <attribute name="DateFormat">dd/MM/yy HH:mm</attribute>
           <attribute name="InitialStartDate">01/01/1970 08:00</attribute>
           <attribute name="SchedulePeriod">86400000</attribute>
           <attribute name="InitialRepetitions">-1</attribute>

          this configurations calls the perform() method in your org.package.MyClass every day at 8:00 (note the InitialStartDate and SchedulePeriod)

          Hope this helps



          • 3. Re: Schedule Reports to Run Daily at Certain Time
            Vassilis Petropoulos Newbie

            i had the same issue. I solved it calling "select count(*) from qrtz_job_details" and if count > 0 just skip. It's not exactly what i wanted but it works. Any better idea from seam team would be welcomed.


            • 4. Re: Schedule Reports to Run Daily at Certain Time
              Patrick Stahmer Newbie

              You can configure your Jboss to not persist the timer:

              in \server\default\deploy\ejb-deployer.xml change persistencePolicy to 'noop':

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