Spring Scheduling:@Scheduled vs Quartz [英] Spring Scheduling: @Scheduled vs Quartz

查看:699
本文介绍了Spring Scheduling:@Scheduled vs Quartz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读春天关于日程安排的3.0 doc 。我倾向于Spring的JobDetailBean for Quartz。但是, @Scheduled 注释引起了我的注意。看来这是使用Spring Framework调度任务的另一种方式。根据文档,Spring提供了三种安排方式:

I'm reading the Spring 3.0 docs regarding scheduling. I'm leaning towards Spring's JobDetailBean for Quartz. However, the @Scheduled annotation has captured my eye. It appears this is another way of scheduling task using the Spring Framework. Based on the docs, Spring provides three way of scheduling:


  1. @Scheduled

  2. Via Quartz

  3. 通过JDK计时器

我对JDK Timer没兴趣。我为什么要选择@Scheduled而不是Quartz? (当我提到Quartz时,我的意思是使用Spring的Bean包装器进行Quartz)。

I have no interest in the JDK Timer. Why should I choose @Scheduled over Quartz? (When I mention Quartz I mean using Spring's bean wrapper for Quartz).

假设我的用例很复杂,我将与第三方Web服务进行通信以指定的时间间隔导入和导出数据。

Let's say my use case is complex enough that I will be communicating to a third-party web service to import and export data at specified intervals.

推荐答案

Quartz比Spring的内置调度程序复杂一个数量级,包括支持用于持久性,事务性和分布式作业。不过,即使使用Spring的API支持,它也有点像猪。

Quartz is an order of magnitude more complex than Spring's built in scheduler, including support for persistent, transactional and distributed jobs. It's a bit of a pig, though, even with Spring's API support.

如果您需要的是每隔X秒或在cron时间表上对bean执行方法,那么 @Scheduled (或Spring的各种选项 < task> 配置架构)可能就够了

If all you need to is to execute methods on a bean every X seconds, or on a cron schedule, then @Scheduled (or the various options in Spring's <task> config schema) is probably enough

这篇关于Spring Scheduling:@Scheduled vs Quartz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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