0
# Configuration Properties
1
2
Type-safe configuration properties for customizing Quartz behavior through `application.properties` or `application.yml`. Provides comprehensive control over scheduler settings, job store configuration, and database initialization.
3
4
## Capabilities
5
6
### QuartzProperties
7
8
Main configuration properties class bound to the `spring.quartz` prefix, providing type-safe access to all Quartz-related settings.
9
10
```java { .api }
11
/**
12
* Configuration properties for Quartz Scheduler integration
13
* Bound to spring.quartz configuration prefix
14
*/
15
@ConfigurationProperties("spring.quartz")
16
public class QuartzProperties {
17
18
/**
19
* Get the job store type (MEMORY or JDBC)
20
* @return JobStoreType enum value (default: MEMORY)
21
*/
22
public JobStoreType getJobStoreType();
23
24
/**
25
* Set the job store type
26
* @param jobStoreType MEMORY for in-memory storage, JDBC for database storage
27
*/
28
public void setJobStoreType(JobStoreType jobStoreType);
29
30
/**
31
* Get the scheduler name
32
* @return Scheduler name or null if not set
33
*/
34
public String getSchedulerName();
35
36
/**
37
* Set the scheduler name
38
* @param schedulerName Name for the scheduler instance
39
*/
40
public void setSchedulerName(String schedulerName);
41
42
/**
43
* Check if scheduler should start automatically after initialization
44
* @return true if auto-startup is enabled (default: true)
45
*/
46
public boolean isAutoStartup();
47
48
/**
49
* Set auto-startup behavior
50
* @param autoStartup true to start scheduler automatically
51
*/
52
public void setAutoStartup(boolean autoStartup);
53
54
/**
55
* Get startup delay duration
56
* @return Duration to wait before starting scheduler (default: 0 seconds)
57
*/
58
public Duration getStartupDelay();
59
60
/**
61
* Set startup delay
62
* @param startupDelay Time to wait before starting scheduler after initialization
63
*/
64
public void setStartupDelay(Duration startupDelay);
65
66
/**
67
* Check if scheduler should wait for jobs to complete on shutdown
68
* @return true if should wait for job completion (default: false)
69
*/
70
public boolean isWaitForJobsToCompleteOnShutdown();
71
72
/**
73
* Set shutdown behavior for running jobs
74
* @param waitForJobsToCompleteOnShutdown true to wait for jobs to complete
75
*/
76
public void setWaitForJobsToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown);
77
78
/**
79
* Check if configured jobs should overwrite existing job definitions
80
* @return true if jobs should be overwritten (default: false)
81
*/
82
public boolean isOverwriteExistingJobs();
83
84
/**
85
* Set job overwrite behavior
86
* @param overwriteExistingJobs true to overwrite existing jobs with same identity
87
*/
88
public void setOverwriteExistingJobs(boolean overwriteExistingJobs);
89
90
/**
91
* Get additional Quartz Scheduler properties
92
* @return Map of property keys to values
93
*/
94
public Map<String, String> getProperties();
95
96
/**
97
* Get JDBC-specific configuration
98
* @return Jdbc configuration object
99
*/
100
public Jdbc getJdbc();
101
}
102
```
103
104
**Usage Examples:**
105
106
```properties
107
# Basic scheduler configuration
108
spring.quartz.scheduler-name=MyAppScheduler
109
spring.quartz.auto-startup=true
110
spring.quartz.startup-delay=10s
111
spring.quartz.wait-for-jobs-to-complete-on-shutdown=true
112
spring.quartz.overwrite-existing-jobs=false
113
114
# Job store selection
115
spring.quartz.job-store-type=memory
116
# or
117
spring.quartz.job-store-type=jdbc
118
119
# Advanced Quartz properties
120
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
121
spring.quartz.properties.org.quartz.scheduler.makeSchedulerThreadDaemon=true
122
spring.quartz.properties.org.quartz.jobStore.useProperties=true
123
spring.quartz.properties.org.quartz.threadPool.threadCount=5
124
```
125
126
```yaml
127
# YAML configuration
128
spring:
129
quartz:
130
scheduler-name: MyAppScheduler
131
auto-startup: true
132
startup-delay: 10s
133
wait-for-jobs-to-complete-on-shutdown: true
134
job-store-type: jdbc
135
properties:
136
org.quartz.scheduler.instanceId: AUTO
137
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
138
org.quartz.jobStore.tablePrefix: QRTZ_
139
org.quartz.jobStore.isClustered: true
140
org.quartz.jobStore.clusterCheckinInterval: 20000
141
```
142
143
### JobStoreType Enum
144
145
Enumeration defining the supported Quartz job store types.
146
147
```java { .api }
148
/**
149
* Enumeration for supported Quartz job store types
150
*/
151
public enum JobStoreType {
152
/**
153
* Store jobs in memory (default)
154
* Jobs and triggers are lost on application restart
155
* Suitable for development and simple scheduling needs
156
*/
157
MEMORY,
158
159
/**
160
* Store jobs in database
161
* Jobs and triggers persist across application restarts
162
* Supports clustering and high availability
163
* Requires DataSource configuration
164
*/
165
JDBC
166
}
167
```
168
169
### JDBC Configuration
170
171
Nested configuration class for JDBC job store specific settings.
172
173
```java { .api }
174
/**
175
* JDBC-specific configuration properties for Quartz
176
* Nested class within QuartzProperties
177
*/
178
public static class Jdbc {
179
180
/**
181
* Get the path to SQL schema initialization script
182
* @return Schema script location (default: classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql)
183
*/
184
public String getSchema();
185
186
/**
187
* Set schema script location
188
* @param schema Path to SQL script for schema initialization
189
*/
190
public void setSchema(String schema);
191
192
/**
193
* Get database platform for schema script selection
194
* @return Platform name (auto-detected by default)
195
*/
196
public String getPlatform();
197
198
/**
199
* Set database platform
200
* @param platform Platform name to use in @@platform@@ placeholders
201
*/
202
public void setPlatform(String platform);
203
204
/**
205
* Get database schema initialization mode
206
* @return DatabaseInitializationMode enum value (default: EMBEDDED)
207
*/
208
public DatabaseInitializationMode getInitializeSchema();
209
210
/**
211
* Set schema initialization mode
212
* @param initializeSchema ALWAYS, EMBEDDED, or NEVER
213
*/
214
public void setInitializeSchema(DatabaseInitializationMode initializeSchema);
215
216
/**
217
* Get prefixes for single-line comments in SQL scripts
218
* @return List of comment prefixes (default: ["#", "--"])
219
*/
220
public List<String> getCommentPrefix();
221
222
/**
223
* Set comment prefixes for SQL script parsing
224
* @param commentPrefix List of strings that start SQL comments
225
*/
226
public void setCommentPrefix(List<String> commentPrefix);
227
}
228
```
229
230
**JDBC Configuration Examples:**
231
232
```properties
233
# JDBC job store configuration
234
spring.quartz.job-store-type=jdbc
235
spring.quartz.jdbc.initialize-schema=embedded
236
spring.quartz.jdbc.platform=postgresql
237
spring.quartz.jdbc.schema=classpath:custom-quartz-schema.sql
238
spring.quartz.jdbc.comment-prefix=#,--,//
239
240
# Database-specific job store properties
241
spring.quartz.properties.org.quartz.jobStore.class=org.springframework.scheduling.quartz.LocalDataSourceJobStore
242
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
243
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
244
spring.quartz.properties.org.quartz.jobStore.misfireThreshold=60000
245
```
246
247
## Advanced Configuration Patterns
248
249
### Clustering Configuration
250
251
```properties
252
# Enable clustering for high availability
253
spring.quartz.properties.org.quartz.jobStore.isClustered=true
254
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=20000
255
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
256
spring.quartz.properties.org.quartz.scheduler.instanceName=MyClusteredScheduler
257
```
258
259
### Thread Pool Configuration
260
261
```properties
262
# Configure thread pool for job execution
263
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
264
spring.quartz.properties.org.quartz.threadPool.threadCount=10
265
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
266
spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
267
```
268
269
### Job Persistence Configuration
270
271
```properties
272
# Job persistence and recovery settings
273
spring.quartz.properties.org.quartz.jobStore.useProperties=true
274
spring.quartz.properties.org.quartz.plugin.jobInitializer.class=org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
275
spring.quartz.properties.org.quartz.plugin.jobInitializer.fileNames=jobs.xml
276
spring.quartz.properties.org.quartz.plugin.jobInitializer.failOnFileNotFound=true
277
```
278
279
## Configuration Validation
280
281
Spring Boot validates configuration properties at startup:
282
283
- **Invalid JobStoreType**: Throws configuration exception
284
- **Missing DataSource**: Falls back to MEMORY when JDBC is specified but no DataSource available
285
- **Invalid Duration format**: Rejects malformed duration strings (e.g., "5x" instead of "5s")
286
- **Conflicting properties**: Warns about conflicting Quartz property combinations
287
288
## Environment-Specific Configuration
289
290
```properties
291
# Development environment
292
spring.profiles.active=dev
293
spring.quartz.job-store-type=memory
294
spring.quartz.auto-startup=true
295
spring.quartz.properties.org.quartz.scheduler.makeSchedulerThreadDaemon=true
296
297
# Production environment
298
spring.profiles.active=prod
299
spring.quartz.job-store-type=jdbc
300
spring.quartz.properties.org.quartz.jobStore.isClustered=true
301
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=20000
302
spring.quartz.startup-delay=30s
303
```