简体   繁体   English

如果我不关机石英调度器会怎样?

[英]What happens if I do not shutdown() quartz scheduler

What would happen if I do not call the shutdown() method on my Quartz scheduler ? 如果不在Quartz scheduler上调用shutdown()方法,会发生什么情况?

I have a job that needs to be run each day at different times the day: 我有一份每天需要在不同时间运行的工作:

    Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

            JobDetail job = newJob(NotificationCronJob.class).withIdentity("notificationJob1", "notificationGroup1").build();

            CronTrigger cronTriggerSunday = newTrigger().withIdentity("notificationTrigger1", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.SUNDAY_NOTIFY))
                    .forJob(job)
                    .build();
            CronTrigger cronTriggerMonday = newTrigger().withIdentity("notificationTrigger2", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.MONDAY_NOTIFY))
                    .forJob(job)
                    .build();
            CronTrigger cronTriggerTuesday = newTrigger().withIdentity("notificationTrigger3", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.TUESDAY_NOTIFY))
                    .forJob(job)
                    .build();
            CronTrigger cronTriggerWednesday = newTrigger().withIdentity("notificationTrigger4", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.WEDENSDAY_NOTIFY))
                    .forJob(job)
                    .build();
            CronTrigger cronTriggerThursday = newTrigger().withIdentity("notificationTrigger5", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.THURSDAY_NOTIFY))
                    .forJob(job)
                    .build();
            CronTrigger cronTriggerFriday = newTrigger().withIdentity("notificationTrigger6", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.FRIDAY_NOTIFY))
                    .forJob(job)
                    .build();
            CronTrigger cronTriggerSaturday = newTrigger().withIdentity("notificationTrigger7", "notificationGroup1")
                    .withSchedule(cronSchedule(Config.SATURDAY_NOTIFY))
                    .forJob(job)
                    .build();

            scheduler.scheduleJob(job, cronTriggerSunday);
            scheduler.scheduleJob(cronTriggerMonday);
            scheduler.rescheduleJob(cronTriggerMonday.getKey(), cronTriggerMonday);
            scheduler.scheduleJob(cronTriggerTuesday);
            scheduler.scheduleJob(cronTriggerWednesday);
            scheduler.scheduleJob(cronTriggerThursday);
            scheduler.scheduleJob(cronTriggerFriday);
            scheduler.scheduleJob(cronTriggerSaturday);

            scheduler.start();

Each Config.DAY is a cron expression fore example 0 0 9 ? * 1 每个Config.DAY是一个cron表达式,例如0 0 9 ? * 1 0 0 9 ? * 1 run each sunday at 9am. 0 0 9 ? * 1每个星期日的上午9点运行0 0 9 ? * 1次。

Now the problem is if I shutdown the scheduler the job would never be run, so therefore I just start it and just let it run. 现在的问题是,如果我关闭调度程序,该作业将永远无法运行,因此,我只启动它并让它运行。 But I am concerned with if that would result in some memory leak og threading problem of some kind, I cannot figure out if this is a well enough solution. 但是我担心这是否会导致某种形式的线程泄漏和内存泄漏,我不知道这是否是一个足够好的解决方案。 My quartz properties are as follows: 我的石英特性如下:

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX

org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.MSSQLDelegate
org.quartz.jobStore.dataSource = myDS
org.quartz.dataSource.myDS.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
org.quartz.dataSource.myDS.URL = jdbc:sqlserver://localhost;databaseName=myDB
org.quartz.dataSource.myDS.user = myUser
org.quartz.dataSource.myDS.password = myPassword
org.quartz.dataSource.myDS.maxConnections = 5
org.quartz.jobStore.tablePrefix = QRTZ_

What I need to achieve in the end is an application that runs a job at the defined times and the scheduling should be mutable without restarting the application. 最后,我需要实现的是一个在定义的时间运行作业的应用程序,并且调度应该是可变的,而无需重新启动该应用程序。

Quartz scheduler shouldn't call 'shutdown' method while your application is running. 当您的应用程序运行时,Quartz Scheduler不应调用'shutdown'方法。 If you found any problem such as memory leak, you can issue the problem to Quartz community. 如果发现任何问题,例如内存泄漏,可以将问题发布给Quartz社区。

If 'shutdown' is called, Quartz scheduler is never restarted even if you call 'start' method again. 如果调用“ shutdown”,即使再次调用“ start”方法,Quartz调度程序也不会重启。

Please refer to the below URL which is Quartz documentation. 请参考以下URL,它是Quartz文档。 http://www.quartz-scheduler.org/documentation/quartz-2.x/cookbook/ShutdownScheduler.html http://www.quartz-scheduler.org/documentation/quartz-2.x/cookbook/ShutdownScheduler.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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