Spring Boot集成Spring Scheduler和Quartz Scheduler

Spring Boot集成Spring Scheduler和Quartz Scheduler

https://blog.51cto.com/7308310/2464491

Scheduling Tasks

https://spring.io/guides/gs/scheduling-tasks/

Spring之——两种任务调度Scheduled和Async

 https://blog.csdn.net/l1028386804/article/details/72494169/

Spring Scheduler的使用与坑

 https://blog.csdn.net/jiangeeq/article/details/81198379

Spring scheduler调度计划

 https://www.jdon.com/springboot/spring-scheduling.html

Quartz持久化到mongodb

https://www.cnblogs.com/liuxm2017/p/12021755.html

michaelklishin / quartz-mongodb

https://github.com/michaelklishin/quartz-mongodb

定时任务框架Quartz的新玩法

https://developer.aliyun.com/article/62959

定时任务知多少(二)——持久化quartz到Mongodb中

https://blog.csdn.net/liu765023051/article/details/48834893

Spring Boot定时任务在分布式环境下的轻量级解决方案

 https://www.jianshu.com/p/41970ba48453?from=timeline&isappinstalled=0

分布式定时任务调度框架选型

 https://www.cnblogs.com/ssslinppp/p/12485273.html

 

spring-boot-starter-quartz集群实践

https://segmentfault.com/a/1190000020043297?utm_source=tag-newest

spring-boot-2.0.3之quartz集成,不是你想的那样哦!

 https://www.cnblogs.com/youzhibing/p/10024558.html

 

How to test Spring @Scheduled

https://stackoverflow.com/questions/32319640/how-to-test-spring-scheduled

基于SchedulingConfigurer的任务调度

https://blog.csdn.net/G0_hw/article/details/94877687

Spring 异步线程池、调度任务线程池配置

https://segmentfault.com/a/1190000012506685

# A MongoDB-based store for Quartz.

This is a MongoDB-backed job store for the [Quartz scheduler](http://quartz-scheduler.org/).

## Maven Artifacts

Artifacts are released to [Bintray](https://bintray.com/michaelklishin/maven/).

If you are using Maven, add the following repository
definition to your `pom.xml`:

``` xml
<repositories>
    <repository>
        <id>michaelklishin</id>
        <url>https://dl.bintray.com/michaelklishin/maven/</url>
    </repository>
</repositories>
```

With Gradle, add the following to your `build.gradle`:

``` groovy
repositories {
    maven {
        url "https://dl.bintray.com/michaelklishin/maven/"
    }
}
```


### The Most Recent Release

With Maven:

``` xml
<dependency>
    <groupId>com.novemberain</groupId>
    <artifactId>quartz-mongodb</artifactId>
    <version>2.2.0-rc2</version>
</dependency>
```

With Gradle:

``` groovy
compile "com.novemberain:quartz-mongodb:2.2.0-rc2"
```


## Usage

Like most things in Quartz, this job store is configured
via a property file, `quartz.properties`:

``` ini
# 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
```


### Error Handling in Clustered Mode

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




### Clojure and Quartzite

If you use [Quartzite](http://clojurequartz.info) or want your job classes to be available
to Clojure code, use:

    org.quartz.jobStore.class=com.novemberain.quartz.mongodb.DynamicMongoDBJobStore

(this assumes Clojure jar is on classpath).

### Job Data storage
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.

``` ini
org.quartz.jobStore.jobDataAsBase64=false
```

## Clustering

To enable clustering set the following property:

``` ini
# 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:

``` ini
org.quartz.scheduler.collectionPrefix=yourCluster
```

Different time settings for cluster operations:

``` ini
# 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
```

## Continuous Integration

[![Build Status](https://secure.travis-ci.org/michaelklishin/quartz-mongodb.png?branch=master)](http://travis-ci.org/michaelklishin/quartz-mongodb)

CI is hosted by [Travis CI](http://travis-ci.org/)


## Copyright & License

(c) Michael S. Klishin, Alex Petrov, 2011-2020.

[Apache Public License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)


## FAQ

### Project Origins

The project was originally started by MuleSoft. It supports all Quartz trigger types and
tries to be as feature complete as possible.

### Why the Fork?

MuleSoft developers did not respond to attempts to submit pull
requests for several months. As more and more functionality was added
and implementation code refactored, I decided to completely separate
this fork form GitHub forks network because the project is now too
different from the original one. All changes were made with respect to
the Apache Public License 2.0.

 

posted @ 2020-10-28 18:30  tonggc1668  阅读(472)  评论(0编辑  收藏  举报