Quartz is configured using a set of properties that are available for the Runtime. Quartz uses a job store in order to persist jobs details, triggers and other job related information. All quartz related properties are stored in application-scheduler-quartz.properties in spring.config.additional-location.
For more information visit Quartz Scheduler Configuration. |
|
Steps:
Steps 3 and 4 are applicable only if a job store database connection is chosen instead of in memory job store. |
Every Quartz configuration property has to be specified in application-scheduler-quartz.properties for Runtime. |
In order to tune resources for job execution we provided a few details about the Thread Pool.
Quartz is configured using a set of properties. Quartz uses a job store in order to persist jobs details, triggers and other job related information. We support two types of job stores:
This is the default configuration for java environments. |
By default memory mode is enabled which should not be used unless for demo's and standalone development. For recommended settings please check the database settings. For memory the following setting should appear in the application-scheduler-quartz.properties.
spring.quartz.job-store-type=memory |
Scripts to create the required database content are provided for the following databases:
There are two types of connection that are supported:
Generate the quartz database with respect to the database used (either oracle or mssql). In the blueriq deliverable there is a scheduler-quartz-component that contains sql scripts. Use the favourite database viewer to run those scripts against the database server.
|
To enable the JDBC Connection the externaldatasources profile must enabled and the following properties have to be used:
spring.quartz.job-store-type=jdbc spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_ // This example we use MSSQL, please check the online quartz documentation which driverDelegateClass to use spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.MSSQLDelegate |
blueriq.datasource.scheduler-quartz.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver blueriq.dataSource.scheduler-quartz.url=jdbc:sqlserver://<server_url>:<port>;databaseName=<database_name>;instance=<instance_name> blueriq.datasource.scheduler-quartz.username=<user> blueriq.datasource.scheduler-quartz.password=<password> |
blueriq.datasource.scheduler-quartz.driverClassName=oracle.jdbc.driver.OracleDriver blueriq.dataSource.scheduler-quartz.url=jdbc:oracle:thin:@<server_url>:<port>:xe blueriq.datasource.scheduler-quartz.username=<user> blueriq.datasource.scheduler-quartz.password=<password> |
JobStoreTX allows Quartz managing quartz related transactions.
JDBCJobStore’s “table prefix” property is a string equal to the prefix given to Quartz’s tables that were created in your database. You can have multiple sets of Quartz’s tables within the same database if they use different table prefixes.
When changing the org.quartz.jobStore.tablePrefix, please change the create scripts accordingly. |
For more information and properties related to the connection JobStoreTX please visit JDBC-JobStoreTX. |
To enable JNDI Connection jndidatasources profile must be activated and the following properties have to be used:
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreCMT spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_ // This example we use MSSQL, please check the online quartz documentation which driverDelegateClass to use spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.MSSQLDelegate spring.quartz.job-store-type=jdbc |
The scheduler always uses the datasource with the name scheduler-quartz which we define inside application-jndidatasources.properties:
// JBoss Example provided that the jndi name is set to java:jboss/jdbc/quartzdb blueriq.datasource.scheduler-quartz.jndiName=java:jboss/jdbc/quartzdb // Tomcat Example provided that the jndi name is set to jdbc/quartzdb blueriq.datasource.scheduler-quartz.jndiName=java:/comp/env/jdbc/quartzdb |
JobStoreCMT relies upon transactions being managed by the application which is using Quartz.
For more information and properties related to the connection JobStoreCMT please visit JDBC-JobStoreCMT. |
If the Database configuration is chosen we recommend to also add the thread pool with the following default values:
Each DCM project gets it's own trigger. The process engine only allows one process engine (one project) to evaluate timers at a time. Setting the threadCount higher then 1 only will only create waiting threads, this means the best setting for threadCount is 1.
The quartz documentation suggests the following configuration: provided that the database allows X connections, then the threadCount should never be higher then X - 3.
Thread Pool properties are the following:
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool spring.quartz.properties.org.quartz.threadPool.threadCount=1 |
For more information and properties related to Quartz ThreadPool, please visit ThreadPool Configuration |
Clustered environment can be configured only for JDBC JobStore (JobStoreTX and JobStoreCMT). |
In order to run the Quartz Scheduler on multiple Runtime instances in a cluster, every Runtime instance has to be identical and have the same projects installed.
Each instance in the cluster needs to have the same application-scheduler-quartz.properties files. You may set different thread pool size on each node.
To read more about quartz clustered environment visit Quartz in Cluster.
To set up quartz in cluster create the following two files and place them in your spring config additional location:
When quartz is used in a clustered environment one must not set the blueriq.processengine.cancel-started-tasks=true. The property can be set in the application-scheduler-quartz.properties file and the default value is false. When a single server is restarted and the blueriq.processengine.cancel-started-tasks is set to true all opened task are reset so they can be opened again. |
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool spring.quartz.properties.org.quartz.threadPool.threadCount=2 spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_ spring.quartz.properties.org.quartz.jobStore.isClustered = true spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval = 90000 spring.quartz.properties.org.quartz.scheduler.instanceName = MyClusteredScheduler spring.quartz.properties.org.quartz.scheduler.instanceId = AUTO spring.quartz.properties.org.quartz.scheduler.skipUpdateCheck = true |
In this section you can find a list of scheduler related properties. These should be placed in a file named application-scheduler-quartz.properties in spring.config.additional-location. These properties are needed to enable or personalize scheduler functionalities from blueriq runtime perspective. |
|
Default configuration file:
blueriq.scheduler-quartz.enable-task-migration=false blueriq.scheduler-quartz.retryInterval=30 |
If the case is locked when a timer job or expiring job is fired a new quartz job will be scheduled. The reschedule interval for this job can be configured in minutes, with a property in application-scheduler-quartz.properties file. The default value is 30 minutes.
blueriq.scheduler-quartz.retryInterval=30 |
Configure the runtime in cloud. For more details about how to do this visit The runtime in the cloud. |
Actions
Default quartz properties will be used because application-scheduler-quartz.properties file is not present. The default setup is in-memory configuration.
Scheduler properties can be personalized via JVM arguments:
-Dblueriq.scheduler-quartz.enable-task-migration=false -Dblueriq.scheduler-quartz.retryInterval=30 |
If no property is defined, the default ones will be used.
Configure a spring.config.additional-location for your application. For more details about how to do this visit Installing Runtime. |
In order for the already scheduled tasks to be executed in time, you need to do a migration to the scheduler.
Before running the migration you need to create the following files and place them in your spring.config.additional-location folder:
For more information regarding migration preconditions read Migration API Preconditions. |
The quartz evaluation of time dependent tasks (timer nodes, tasks with priority algorithms, expiration tasks, automatic recovery tasks) is done per Process Engine per Project installed on the Runtime. A quartz job is created for every single project which uses a process engine in the cluster. The number of jobs in Quartz equals with the number of initialized projects from the cluster which are using a process engine. The number of jobs in quartz does not depend on the number of runtime instances available in the cluster.
An interval is defined in the application.properties file which marks the triggering and execution of the job. If the interval is MINUTE, the quartz job will be triggered and executed every minute. The execution consists in finding and evaluating all the timer tasks, expiration tasks, tasks with priority which should fire in that period.
The Runtime instances are selected for execution almost randomly, more busy servers have a lower chance to be selected for the execution.The main advantage for this is that: As multiple runtime instances are available in cluster, the execution of the jobs might be done in parallel.
The quartz job is created in the cluster when the project which uses a process engine is initialized. This means whenever a project is published and the process engine is initialized in a Runtime, that Runtime will try to start the job for the project if the job is not already created.
The execution of quartz jobs is being done on any Runtime in the cluster as soon as the Runtime is started. This might happen even though in that Runtime no projects are published yet.
The quartz evaluation of a timer task, a expiration task, a task with priority or an automatic task is done per task. A quartz job is created for every task which has one of the types described earlier. The number of jobs in quartz equals with the number of timer, expiration and task with priority which have to be evaluated in the future.
Every job fires exactly at the time it was modelled without re-checking this at an interval as the basic scheduler did. The runtime instances are selected randomly and the execution of a job can happen on any of those instances in parallel.
There might be a side scenario in which one runtime in a cluster does not have all the projects available but it is started. In this case, Quartz might trigger a job on that server without having a project to run on. If this happens the job for that project is deleted and won't trigger until the project is loaded - this usually means that there is a configuration problem in the cluster. Loading/publishing a project in a Runtime will trigger the creation of the job in the cluster if the job doesn't already exist. If you're uncertain that a job is running or not, you can check the logs. Starting or deleting a job is always logged. Besides this you can check the quartz database. In the table QRTZ_JOB_DETAILS there should be a column JOB_NAME. That field should contain the project and process engine name for which that job was created. It is very recommended that no changes to be done in quartz tables and you let only Quartz manage the data there. |
For more information on quartz configurations, please visit: Quartz-Scheduler.org. |
If you want to run multiple runtimes on one machine, Atomikos tends to fail to access it's transaction log. This will result in a runtime that doesn't start. To fix this problem, add a VM argument to one of your runtimes to set the folder of the Atomikos transaction log files to something other than the default (which is '
For more information please refer to the Atomikos documentation https://www.atomikos.com/Documentation/JtaProperties#Transaction_logs |