2 Replies Latest reply on Apr 6, 2010 3:49 AM by Nikolay Elenkov

    How To Update Trigger in Async Call

    Shane Sarver Newbie

      Using an injected QuartzTriggerHandle, how can you update the Quartz trigger in the database
      so that the change overrides the initial values assigned to @Expiration, @IntervalDuration, @FinalExpiration
      and are used by the Quartz scheduler in subsequent job runs?



          @Asynchronous
          @Transactional
          public QuartzTriggerHandle schedulePayment(
                                       @Expiration Date when,
                                       @IntervalDuration Long interval,
                                       @FinalExpiration Date stoptime,
                                       Long paymentId) throws Exception { ... }

        • 1. Re: How To Update Trigger in Async Call
          Shane Sarver Newbie

          Reformatted:


              @Asynchronous
              @Transactional
              public QuartzTriggerHandle schedulePayment(
                                           @Expiration Date when, 
                                           @IntervalDuration Long interval, 
                                           @FinalExpiration Date stoptime, 
                                           Long paymentId) throws Exception { ... }





          • 2. Re: How To Update Trigger in Async Call
            Nikolay Elenkov Master

            Here is what I use:


            QuartzDispatcher dispatcher = QuartzDispatcher.instance();
            Scheduler scheduler = dispatcher.getScheduler();
            
            SimpleTrigger trigger = new SimpleTrigger(triggerName,
                            triggerGroup, jobName, jobGroup,
                            when, null, SimpleTrigger.REPEAT_INDEFINITELY, interval);
            
            scheduler.rescheduleJob(triggerName, triggerGroup, trigger);
            



            If you are willing to use patched version of Seam, there is this: JBSEAM-4399. This allows you to set meaningful names for your jobs/triggers (as opposed to the UIDs Seam generates). You can get the job/trigger names from the QuartzTriggerHandle. Seam uses the Scheduler.DEFAULT_GROUP for trigger/job group.