This is a fork of michaelklishin/quartz-mongodb.
You can download this library from our artifactory.
Direct link is https://packages.nuxeo.com/service/rest/repository/browse/maven-public/org/nuxeo/lib/novemberain/.
Or with Maven:
<project>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nuxeo.lib.novemberain</groupId>
<artifactId>quartz-mongodb</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
</dependencyManagement>
...
<repositories>
<repository>
<id>nuxeo-public</id>
<url>https://packages.nuxeo.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<updatePolicy>always</updatePolicy>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
...
</project>
This is a MongoDB-backed job store for the Quartz scheduler.
Like most things in Quartz, this job store is configured
via a property file, quartz.properties
:
# Use the MongoDB store
org.quartz.jobStore.class=com.novemberain.quartz.mongodb.MongoDBJobStore
# MongoDB URI (optional if 'org.quartz.jobStore.addresses' is set)
org.quartz.jobStore.mongoUri=mongodb://localhost:27020
# comma separated list of mongodb hosts/replica set seeds (optional if 'org.quartz.jobStore.mongoUri' is set)
org.quartz.jobStore.addresses=host1,host2
# database name
org.quartz.jobStore.dbName=quartz
# Will be used to create collections like mycol_jobs, mycol_triggers, mycol_calendars, mycol_locks
org.quartz.jobStore.collectionPrefix=mycol
# thread count setting is ignored by the MongoDB store but Quartz requries it
org.quartz.threadPool.threadCount=1
When running in clustered mode, the store will periodically check in with the cluster. Should that operation fail, the store needs to decide what to do:
- Shut down
- Do nothing and optimistically proceed
Different strategies make sense in different scenarios. Pausing Quartz would be optimal but this job store currently doesn't have that option.
The org.quartz.jobStore.checkInErrorHandler.class
property controls the error handler
implementation.
To shut down the JVM (which is the default), add the following key to quartz.properties
org.quartz.jobStore.checkInErrorHandler.class=com.novemberain.quartz.mongodb.cluster.KamikazeErrorHandler
to ignore the failure:
org.quartz.jobStore.checkInErrorHandler.class=com.novemberain.quartz.mongodb.cluster.NoOpErrorHandler
By default you are allowed to pass any java.io.Serializable
objects inside JobDataMap
.
It will be serialized and stored as a base64
string.
If your JobDataMap
only contains simple types, it may be stored directly inside MongoDB to save some performance.
org.quartz.jobStore.jobDataAsBase64=false
To enable clustering set the following property:
# turn clustering on:
org.quartz.jobStore.isClustered=true
# Must be unique for each node or AUTO to use autogenerated:
org.quartz.scheduler.instanceId=AUTO
# org.quartz.scheduler.instanceId=node1
# The same cluster name on each node:
org.quartz.scheduler.instanceName=clusterName
Each node in a cluster must have the same properties, except instanceId. To setup other clusters use different collection prefix:
org.quartz.scheduler.collectionPrefix=yourCluster
Different time settings for cluster operations:
# Frequency (in milliseconds) at which this instance checks-in to cluster.
# Affects the rate of detecting failed instances.
# Defaults to 7500 ms.
org.quartz.jobStore.clusterCheckinInterval=10000
# Time in millis after which a trigger can be considered as expired.
# Defaults to 10 minutes:
org.quartz.jobStore.triggerTimeoutMillis=1200000
# Time in millis after which a job can be considered as expired.
# Defaults to 10 minutes:
org.quartz.jobStore.jobTimeoutMillis=1200000
# Time limit in millis after which a trigger should be treated as misfired.
# Defaults to 5000 ms.
org.quartz.jobStore.misfireThreshold=10000
# WriteConcern timeout in millis when writing in Replica Set.
# Defaults to 5000 ms.
org.quartz.jobStore.mongoOptionWriteConcernTimeoutMillis=10000
(c) Michael S. Klishin, Alex Petrov, 2011-2020.
Make sure the project builds and its tests pass.
Then create a temporary branch to perform the release:
git checkout -b tmp-release
Then update the project version to final, for instance 2.3.0:
mvn versions:set -DnewVersion=2.3.0 -DgenerateBackupPoms=false
Then commit and tag the release:
git commit -a -m "Release 2.3.0"
git tag -a -m "Release 2.3.0" quartz-mongodb-2.3.0
Then deploy the maven artefacts:
mvn clean source:jar deploy -DskipTests -DaltDeploymentRepository=maven-vendor::default::VENDOR_URL
Important
You should replace the VENDOR_URL
.
Your Maven settings.xml
file should contain appropriate authentication (if any) for the maven-vendor
repository.
Then push the tag:
git push --tags
Then cleanup your branch and prepare the next development iteration:
git checkout master
git branch -D tmp-release
mvn versions:set -DnewVersion=2.3.1-SNAPSHOT -DgenerateBackupPoms=false
git commit -a -m "Post release 2.3.0"
git push