Job.Execute triggers while scheduling the job with passed StartTimeUTC

49 views
Skip to first unread message

tamil

unread,
Mar 24, 2012, 8:00:03 AM3/24/12
to Quartz.NET, tami...@jijitech.com
Hi all,
I am new to Quartznet schedulers. I am trying to implement
"CalendarIntervalTriggerImpl" trigger. I set a passed date (a day in
2010 year) to the trigger.

When I call the ScheduleJob method by passing the Jobdetail
& Triggers, it immediately triggers the Job.Execute method. Whether I
am missing anything. Please guide me in correct way.


Thanks,
Tamil

Nuno Maia

unread,
Mar 25, 2012, 6:22:23 PM3/25/12
to quar...@googlegroups.com, tami...@jijitech.com
Hi,

Can you paste the code that are you using to schedule the job ?

> --
> You received this message because you are subscribed to the Google Groups "Quartz.NET" group.
> To post to this group, send email to quar...@googlegroups.com.
> To unsubscribe from this group, send email to quartznet+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/quartznet?hl=en.
>

tamilmani araichimani

unread,
Mar 26, 2012, 1:37:15 AM3/26/12
to quar...@googlegroups.com
Thanks for you reply Nuno. Please have a look at the following code,

    class Program
    {
        private static IScheduler _scheduler;

        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now.Day);
            ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
            _scheduler = schedulerFactory.GetScheduler();
            _scheduler.Start();
            AddJob();
        }

        public static void AddJob()
        {
            IJob myJob = new MyJob(); //This Constructor needs to be parameterless
            JobDetailImpl jobDetail = new JobDetailImpl("Group1", "Group1", myJob.GetType());
            CalendarIntervalTriggerImpl trigger = new CalendarIntervalTriggerImpl("Group1", "Group1", IntervalUnit.Week, 2);
            trigger.StartTimeUtc = DateTime.Now.AddDays(-3).AddSeconds(15);
            _scheduler.ScheduleJob(jobDetail, trigger);
            Console.WriteLine("Next : {0}", trigger.GetNextFireTimeUtc().Value.ToLocalTime());
        }
    }

    internal class MyJob : IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Executing the job...");
        }
    }

when the line " _scheduler.ScheduleJob(jobDetail, trigger);" hits, it immediately executes the "Job.Execute" method. Please guide me.

Mark Gillen

unread,
Mar 26, 2012, 7:22:48 AM3/26/12
to quar...@googlegroups.com
Hi Tamilani,

Sorry if I'm coming to the thread a bit late but whey are you setting the start date to be in the past by 3+ days?

trigger.StartTimeUtc = DateTime.Now.AddDays(-3).AddSeconds(15);


I can see if the refire policy is set to "Skip" where this might not make a difference...sorry if this is a dumb question...I use these emails as a chance to learn as well...

Best Regards,
Mark Gillen

Nuno Maia

unread,
Mar 27, 2012, 9:29:22 AM3/27/12
to quar...@googlegroups.com
By defining a paste date you are forcing a misfire. Define a proper
misfire policy to skip to next execution date.

tamilmani araichimani

unread,
Mar 28, 2012, 3:36:52 AM3/28/12
to quar...@googlegroups.com
Thanks Nuno, I will try define a misfire policy and let you know the result.
Reply all
Reply to author
Forward
0 new messages