====== Quartz - Scheduling Overview ====== Author: David McGee **Introduction** Quartz is [1] an open source job scheduling library that can be integrated within a Java application. It can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that may execute virtually anything you may program them to do. Quartz is freely usable, licensed under the Apache 2.0 license. Errigal utilise Quartz for scheduling of jobs across the IDMS platform. This may be open to future improvements! **Configuration** Using the **thread_config** table of the **SnmpManager** database, one can specify on which servers running the Quartz a specific job type should run (e.g. apps1 only runs CONFIG_SYNC and apps2 only runs SYNC_SCHEDULER). **thread_config** example ("select * from thread_config"): | **id** | **failover_hostname** | **hostname** | **is_active** | **type** | **params** | **application_port** | | 44 | lb1 | lb1 | | DISTRIBUTOR | NULL | 8442 | | 45 | apps1 | apps1 | | HANDLER | NULL | 8442 | | 46 | apps2 | apps2 | | HANDLER | NULL | 8442 | | 49 | apps1 | apps1 | | CONFIG_SYNC | NULL | 8442 | | 55 | apps2 | apps2 | | SYNC_SCHEDULER | NULL | 8442 | **Grails Plugin** The grails quartz plugin [2] adds Quartz job scheduling features to the Grails framework by wrapping the quartz scheduling library in a plugin. This is possible through specifying the appropriate version of the Quartz plugin via an IDMS application's BuildConfig.groovy (Example: compile ':quartz:1.0.1'). Use of the Grails Quartz plugin at Errigal has been a mixed bag. It has both helped and hindered development at times. Some issues have occurred around clustering. **Scheduling a Job** Please find an example from the [3] official plugin documentation: {{:onboarding:snmpmanager:quartz_-_job_schedule.png|}} **Scheduling a Cron Job** Please find an example from the [3] official plugin documentation: {{:onboarding:snmpmanager:quartz_-_cron_schedule.png|}} **Errigal Support - Quartz Issues observed** * Fully Blocked jobs - One of the most common issues observed in production involves Quartz jobs becoming blocked/hung. Errigal Watchdog monitors for occurrences of this and triggers QuartzJobBlocked alarms for these event types. A quick search in the Errigal Support Evernote repository will give you some tips on how to resolve this. Please consult with a colleague before trying this. **Self-assessment** - Find out how to unblock a blocked quartz job, for your own knowledge. This shouldn't be run on a QA or production system. - Identify the current Grails quartz plugin being used across the IDMS applications. BitBucket is your friend, here! - Find 1 quartz job in each of the IDMS applications: SNMP Manager, Ticketer, Reporting Manager and NOC Portal. Take a look at how the jobs are written. **Resources** [1] [[http://www.quartz-scheduler.org/|Quartz Scheduler - Official Website]] [2] [[https://grails.org/plugin/quartz|Grails - Quartz Plugin]] [3] [[http://grails-plugins.github.io/grails-quartz/|Grails - Plugin Documentation]]