使用 java.util.timer 与 Quartz 进行调度的优缺点? [英] Pros and cons of using java.util.timer vs Quartz for scheduling?

查看:26
本文介绍了使用 java.util.timer 与 Quartz 进行调度的优缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个执行一系列任务的应用程序:

I've got to write an app that performs a series of tasks:

  1. 每天 0200 小时运行一次的任务.
  2. 每天 0400 小时运行一次的任务
  3. 从 0003 小时开始每隔 15 分钟运行一次任务
  4. 从 0005 小时开始每隔 15 分钟运行一次任务

使用普通 java.util.timer 与使用 java.util.timer 的优缺点是什么?石英?

What are the pros and cons of using plain java.util.timer Vs. Quartz for this?

我还应该考虑其他替代方案吗?

Are there any other alternatives I should be considering?

推荐答案

Quartz

  • 额外的依赖
  • API 当前(2011 年末)正在发生变化:1.x 即将推出,但 Spring 和其他可能支持的唯一 API
  • 作业可以持久存储;多个调度器可以集群化以实现负载平衡和故障转移
  • Job 和 Trigger 之间的区别需要一点时间来适应 - 但有可能
  • 更强大的重复调度表达式(例如,用于 cron 表达式的 CronTrigger)
    • 随附开箱即用的 JSE 1.3+
    • 对于您的功能来说可能就足够了
    • 不太灵活,但也不太复杂

    我个人在 Web 应用程序中使用 Quartz + 持久存储,在该应用程序中可以交互地创建触发器并且应该使用 Spring 的调度抽象.恕我直言,这两个 API 都缺乏一个重要的概念:在一段时间后重试失败的任务.为我自己添加这个对于应该重试的重复任务来说很痛苦.

    I am personally using Quartz + persistent storage for a Web application where triggers can be created interactively and should survive restarts, using Spring's scheduling abstraction. Both APIs IMHO lack an important concept: retrying failed tasks after a certain period of time. Adding this for myself was a pain for repeated tasks that should be retried as well.

    这篇关于使用 java.util.timer 与 Quartz 进行调度的优缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆