Quartz Theory of Timed Task Java Writing Review (1)

 

Summary of Java Writing of Scheduled Tasks

 

At present, the timing task mechanisms I have used are mainly divided into three categories: OS -level Linux crontab command method, Java language-level JDK built -in API , third-party API interfaces such as Quartz (of course, other MVC frameworks such as Spring are more human - based based on Quartz . API interface, such interfaces are grouped into the Quartz class family).

 

 

 

Compared with these three methods, the OS level does not need to specifically open the listener, which occupies less system resources, and is the preferred implementation method for timed tasks; JDK comes with APIs mainly Timer and TimeTask . The interface functions provided by these APIs are simple and often cannot satisfy User timed task setting needs; Quartz is an API written in Java language , which can be deployed separately or embedded in existing code as a module of the system, by enabling monitoring to trigger timed tasks. Relatively speaking, especially with this The way to open a large number of monitors is very resource-intensive.

 

 

 

The following describes the three commonly used timing task implementation methods.

 

 

3. Third-party API interface such as Quartz

Quartz is a task schedule management system that can be integrated or used with any other software system. In short, a " task progress manager " is a system that is responsible for executing (or notifying) other software components when a predetermined (scheduled) time arrives.

 

Quartz is fairly " lightweight " and requires very few steps / configuration, and if the requirements are relatively basic, Quartz is really easy to use.

Quartz is fault tolerant and can persist (remember) scheduled tasks when your system is restarted.

3.1 Introduction to Quartz Features

 

Quartz Features:

Quartz can be embedded into any standalone application to run.

Quartz can be instantiated in an application server or servlet container and can participate in XA transactions.

Quartz can run in a stand-alone mode (in its own Java virtual machine), and Quartz can be used through RMI .

Quartz can be instantiated as a cluster of independent programs (with load balancing and fault tolerance)

3.2 Looking at Quartz from a Software Component Perspective

Quartz ships with a small Java library ( .jar file) that contains all of the Quartz core functionality. The main interface (API) for these functions is the Scheduler interface. It provides simple operations such as: adding or canceling tasks to the schedule, starting / stopping / pausing schedule progress.

如果你想将软件组件的执行纳入到日程中,它们只需简单地实现Job接口,这个接口有一个execute()方法。如果希望在日程安排的时间到达时通知组件,那么这些组件应实现TriggerListener或者JobListener接口。

Quartz主过程可以在应用中启动或者运行,也可以作为一个独立的应用(带有RMI接口),或者在一个J2EE 应用服务器中运行,并且可作为其它J2EE组件的一种引用资源。

 

3.3 为什么不使用java.util.Timer?

JDK1.3开始,Java有了内建的定时器功能,即通过java.util.Timerjava.util.TimerTask来实现,为什么有人用Quartz而不用这些标准特性呢?有很多原因,下面是其中的一些:

1. Java定时器没有持久化机制。

2. Java定时器的日程管理不够灵活(只能设置开始时间、重复的间隔,设置特定的日期、时间等)

3. Java定时器没有使用线程池(每个Java定时器使用一个线程)

4. Java定时器没有切实的管理方案,你不得不自己完成存储、组织、恢复任务的措施。

一言以蔽之,这两个新类可以实现一个最基本的调度器。也就只能作为我们理想的完整调度器框架的一个小的部件。任何严格意义的作业调度器都提供直接指定执行时间,存储作业信息到多种介绍和使用钩子进行定制及其他更多的功能。单纯靠JDK的那两个类还不足以构建一个真正的作业调度器。JAVATimer类也没办法对作业和触发器作相应的组织,使用每任务一个线程,而不是线程池的方式,还有其他不足之处难以成全其实现一个完全意义的作业调度器。

 

流行的几个解决方案

Flux Schedulerwww.fluxcorp.com/

Enterprise Batching Queuing    www.argent.com/p/qe/qe.html

Unicenter AutoSys Job Management 4.5www.ca.com

BMC Software ControlM     www.bmc.com

Cybermation ESP Espresso 4.2    www.cybermation.corly;9'm

 

Vexus consulting Avatar Job Scheduling Suite 4.5.5        www.vexus.ca

 

Argent software The Argent Job Scheduler 4.5A    www.argent.com

 

Tidal Enterprise Scheduler  www.tidalsoftware.com

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988390&siteId=291194637
Recommended