简体   繁体   中英

Multi Job with Quartz Scheduler not running

I've scheduled three job in my Service

public partial class Service : ServiceBase
    {
        private IScheduler scheduler;
        private static log4net.ILog _logFile =
            log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public Service()
        {
            InitializeComponent();
        }

        protected override async void OnStart(string[] args)
        {
            _logFile.Info("Service OnStart");

            var factory = new StdSchedulerFactory();
            scheduler = await factory.GetScheduler();

            await scheduler.Start();
            var job = JobBuilder.Create<SearchJob>()
                .WithIdentity("SearchJob", "group1")
                .Build();

            var trigger = TriggerBuilder.Create()
                .WithIdentity("SearchJobtrigger", "group1")
                .StartNow()
                .WithCronSchedule(Settings.Default.SearchCronExp)
                .ForJob(job)
                .Build();

            var jobUpload = JobBuilder.Create<UploadJob>()
           .WithIdentity("UploadJob", "group1")
           .Build();

            var triggerUpload = TriggerBuilder.Create()
                .WithIdentity("TriggerUploadJob", "group1")
                .StartNow()
                .WithCronSchedule(Settings.Default.UploadCronExp)
                .ForJob(jobUpload)
                .Build();

            var jobAwaiter = JobBuilder.Create<AwaiterJob>()
                .WithIdentity("AwaiterJob", "group1")
                .Build();

            var triggerAwaiterJob = TriggerBuilder.Create()
                .WithIdentity("triggerAwaiterJob", "group1")
                .StartNow()
                .WithCronSchedule(Settings.Default.AwaiterCronExp)
                .ForJob(jobAwaiter)
                .Build();

            await scheduler.ScheduleJob(job, trigger);
            await scheduler.ScheduleJob(jobUpload, triggerUpload);
            await scheduler.ScheduleJob(jobAwaiter, triggerAwaiterJob);

            _logFile.Info("End Service OnStart");
        }

        protected override async void OnStop()
        {
            _logFile.Info("Service OnStop");
            await scheduler.Shutdown();
        }
    }

Consulting the log, I notice that the only the first job starts, the other two never start but there are no errors in the log. I tested the service in debug and the jobs are executed correctly, while installing the service compiled in Release no, the three services have a CronExp of 1,10,30 minutes respectively between one execution and the other

错误是由于 CronExp 的值不正确

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM