jobscheduler-parent 1.4.0

A Database driven Job Scheduler library

Лицензия

Лицензия

MIT
Группа

Группа

de.laetsch-it.jobscheduler
Идентификатор

Идентификатор

jobscheduler-parent
Последняя версия

Последняя версия

1.4.0
Дата

Дата

Тип

Тип

pom
Описание

Описание

jobscheduler-parent 1.4.0
A Database driven Job Scheduler library
Ссылка на сайт

Ссылка на сайт

https://github.com/lexx911/jobscheduler
Система контроля версий

Система контроля версий

https://github.com/lexx911/jobscheduler

Скачать jobscheduler-parent

Имя Файла Размер
jobscheduler-parent-1.4.0.pom 3 KB
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/de.laetsch-it.jobscheduler/jobscheduler-parent/ -->
<dependency>
    <groupId>de.laetsch-it.jobscheduler</groupId>
    <artifactId>jobscheduler-parent</artifactId>
    <version>1.4.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/de.laetsch-it.jobscheduler/jobscheduler-parent/
implementation 'de.laetsch-it.jobscheduler:jobscheduler-parent:1.4.0'
// https://jarcasting.com/artifacts/de.laetsch-it.jobscheduler/jobscheduler-parent/
implementation ("de.laetsch-it.jobscheduler:jobscheduler-parent:1.4.0")
'de.laetsch-it.jobscheduler:jobscheduler-parent:pom:1.4.0'
<dependency org="de.laetsch-it.jobscheduler" name="jobscheduler-parent" rev="1.4.0">
  <artifact name="jobscheduler-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='de.laetsch-it.jobscheduler', module='jobscheduler-parent', version='1.4.0')
)
libraryDependencies += "de.laetsch-it.jobscheduler" % "jobscheduler-parent" % "1.4.0"
[de.laetsch-it.jobscheduler/jobscheduler-parent "1.4.0"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

  • jobscheduler
  • jobscheduler-jdbc

Database Job Scheduler version badge

Overview

This library provides a job scheduling mechanism for Spring based projects. All Jobs are configured and managed with a database table.

Features

  • All Jobs configured in one database table.
  • Jobs can run in multithreaded or clustered environments. Synchronisation is done through the database.
  • Sentinel feature to detect hanging or killed Jobs.
  • Job implementations are simple Spring Beans
  • Various RDBMS supported through JPA
  • There is also a plain JDBC variant jobscheduler-jdbc available.

Job Configuration Table

Field Type Description
NAME VARCHAR Unique Name of Job (Primary Key)
CRON_EXPRESSION VARCHAR 6 Fields separated by space: second minute hour day month weekday. See Quartz CronExpression
IMPLEMENTATION VARCHAR Spring Bean name of Job implementation
NEXT_RUN TIMESTAMP Time for next run, evaluated from cron expression or schedule on every run
SCHEDULE VARCHAR Optional: bean name for schedule. Default: CronSchedule
PARAMS VARCHAR Optional: Parameters for Job implementation
RUNNING BOOLEAN Set by scheduler if Job is running
SUSPENDED BOOLEAN Temporarily suspend a Job
DISABLED BOOLEAN Permanently disable a Job
RUN_QUEUE VARCHAR Optional: Group Jobs in queues for serial execution. See below.
LAST_EXECUTION_ID NUMBER Reference to last execution
ERROR_MAIL_ADDRESS VARCHAR Optional, not used by Jobscheduler. May be used by JobLifecycleCallback

Every Job execution is logged in JOB_EXECUTION Table

Run queues

You can group several jobs into run queues. Within one run queue no jobs will run in parallel. In other words, a job will not run if there is another running job with the same run queue. Jobs with different or empty (null) run queues will run in parallel to each other.

Installation

Include maven dependency in your pom.xml:

    <dependency>
        <groupId>de.laetsch-it.jobscheduler</groupId>
        <artifactId>jobscheduler</artifactId>
        <version>1.4.0</version>
    </dependency>

Spring Boot applications

Just annotate your main application class with @EnableJobScheduler

Other Spring applications

  • Include de.lit.jobscheduler.JobSchedulerAutoConfiguration in your Spring Context
  • Add two Entity classes from de.lit.jobscheduler.entity package to your persistance unit: JobDefinition, JobExecution

Configuration options

Property name Type Description
application.jobscheduler.enable Boolean Disable jobscheduler completely with this set to false. Useful for tests. Default: true
application.jobscheduler.initialDelay Long Initial delay in milliseconds until jobscheduler starts scanning job table and executing jobs. Default: 10000
application.jobscheduler.runinterval Long Interval in milliseconds for scanning job table for next due run. Default: 20000
application.jobexecutor.corepoolsize Integer Minimum number of threads kept alive in the thread execution pool. Default: 1
application.jobexecutor.maxpoolsize Integer Max number of threads in the thread execution pool. Default: 4
application.jobscheduler.sentinel.enable Boolean Enable sentinel feature. Default: false
application.jobscheduler.sentinel.graceperiod Long Period in minutes until a sign_of_life is considered old (dead). Default: 15
application.jobscheduler.sentinel.update.initial Long Initial delay in milliseconds until sentinel starts updating sign_of_life. Default: 60000
application.jobscheduler.sentinel.update.interval Long Interval in milliseconds for updating sign_of_life. Default: 20000
application.jobscheduler.sentinel.initialDelay Long Initial delay in milliseconds until sentinel starts checking for hanging jobs. Default: 70000
application.jobscheduler.sentinel.runinterval Long Interval in milliseconds for sentinel to check for hanging Jobs. Default: 900000 (15m)

Sentinel feature

If the sentinel feature is enabled then two things happen:

  1. For every currently running job the sign-of-life-time (in Table JOB_EXECUTION) is updated at the configured interval (default 20 seconds).
  2. The sentinel service checks regularly if a job execution is marked as RUNNING but the sign-of-life-time is too old (grace period default 15 minutes). If such a job is found then this job will be marked as ABORTED, all lifecycle hooks called and reset to not running. The job can then run again at its scheduled time.

This works perfectly well in clustered environments. If one node gets stuck, for instance because of an out of memory exception or JVM crash, then the other nodes will detect and reset all jobs 'hanging' in the failing instance.

Версии библиотеки

Версия
1.4.0
1.3.0
1.2.2
1.2.1
1.2.0
1.1.6