在Spring中使用Quartz任务调度支持集群

Tue Oct 07 16:23:11 CST 2008发表于搜斧SearchFull

虽然在 Quartz上有 配置Quartz集群Clustering ,但是在Spring中使用Quartz任务调度并支持集群系统却有些问题,下面介绍解决办法:

Read more...

阅读全文...
 
本站相关内容:(RSS)

在Spring 中使用quartz实现作业调度


网站: JavaEye  作者: lirengang  链接: http://lirengang.javaeye.com/blog/189346  发表时间: 2008年05月04日

声明:本文系JavaEye网站发布的原创博客文章,未经作者书面许可,严禁任何网站转载本文,否则必将追究法律责任!

一、Quartz

OpenSymphony 的Quartz提供了一个比较完美的任务调度解决方案。
Quartz 是个开源的作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制。
Quartz中有两个基本概念:作业和触发器。作业是能够调度的可执行任务,触发器提供了对作业的调度.

二、Spring 与Quartz的集成
创建一个Job 如下:
package com.ideal

public class EmailReportJob extends QuartzJobBean {

  public EmailReportJob() {
 
  }

  protected void executeInternal(JobExecutionContext context) throws JobExecutionException {

       //do action 
    } 
}
在Spring配置文件里配置 EmailReportJob

<bean id="reportJob"
  class="org.springframework.scheduling.quartz.JobDetailBean">
  <property name="jobClass">
   <value>com.ideal. EmailReportJob </value>
  </property>
 </bean>

配置CronTriggerBean 触发器

<bean id="reportCronTrigger"
  class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail">
   <ref bean="reportob" />
  </property>
  <property name="cronExpression">
   <!-- 关键在配置此表达式 -->
   <value>0 0/1 14 * * ?</value>
  </property>
 </bean>

配置调度 触发器的bean

<bean id="scheduler"
  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  <property name="triggers">
   <ref bean="reportCronTrigger" />
  </property>
 </bean>

 


本文的讨论也很精彩,浏览讨论>>


JavaEye推荐



Quartz and Spring

Xebia Blog

Quartz is a Java Framework for scheduling. It allows applications to schedule tasks for execution in the future. Spring is a Java IoC container. It helps glue together the components that make up an application. This blog elaborates on where the two meet and how they can work together to make developing your application easier. Parameterized [...]

A Simple Quartz/Spring Example

My current project requires the ability to schedule and manage tasks based upon a time interval or specific time. After looking at Java’s TimerTask, I started thinking that I might need something a little more powerful. A buddy of mine said he had great success using Quartz to manage scheduled tasks. He said It is extremely easy to use and it works so well the Spring developer’s have created helper classes to make it easier to integrate into a Spring application. It also has a larger featur

Spring scheduling using Quartz

Even the fact that the Spring Scheduling Documentation is complete, I will show a really simple example to configure Spring with Quartz (in memory). First of all, we need to set up the SchedulerFactoryBean which will set up a Quartz Scheduler. We could define JobDetails, Calendars and Triggers. Let’s define only a simple trigger:

Quartz Job Scheduling Framework[翻译]第十章. J2EE 中使用 Quartz (第一部分)

     摘要: Java 2 平台企业版定义了基于组件的企业应用开发标准。不管你是否倾向于使用一种开源的 J2EE 服务器,比如 JBoss 或 Geronimo,或者你更希望得到可靠安全的商业服务支持,比如 WebSphere 和 WebLogic,你都能在那些应用服务器中使用几种不同的部署方式使用 Quartz。本章给你示范了在 J2EE 应用服务器中以不同策略部署 Quartz,你也会看到 Quartz 框架更加丰富了 J2EE。

一:假如我有 J2EE,为什么还需要 Quartz?

自从 20 世纪 90 年代末期 J2EE 首次登上舞台以来,开发人员就被某些规格决议和一些表面看来明显缺失的特征所困惑。这没必要去批判规格的制定者,更多的是说明了当有不同意见和议程的独立团体,在尝试达成统一的优先级时,就像联合国进行决议时那样,并不如所想像的那样好。许多必须的特征获得认可,但是一些关键的特征被略去留待以后加入。其中一个让早期规范遗漏的关键特征就是定时器服务。   阅读全文

隔叶黄莺 2007-12-08 01:19 发表评论
互联网相关内容:
在Spring 中使用quartz实现作业调度 (2008年05月04日)
Quartz and Spring (2007年09月14日)
A Simple Quartz/Spring Example (2007年12月18日)
Spring scheduling using Quartz (2008年02月02日)
Quartz Job Scheduling Framework[翻译]第十章. J2EE 中使用 Quartz (第一部分) (2007年12月08日)
Quartz Job Scheduling Framework[翻译]第十章. J2EE 中使用 Quartz (第二部分) (2007年12月09日)
Spring, Quartz and Auto-wiring of Quartz jobs (2008年01月17日)
Using OpenSymphony Quartz Scheduler in Spring (2008年02月22日)
Starting Quartz Server using Spring (2008年04月23日)