Spring中Quartz的Job顺序执行

本文探讨了在Spring中使用Quartz时如何处理任务的顺序执行。默认情况下,Quartz任务会并发执行,但通过调整Spring XML配置,特别是设置MethodInvokingJobDetailFactoryBean的concurrent属性,可以实现任务的顺序执行。同时,文中提供了相关的代码示例和原码解析,以帮助理解这一过程。
摘要由CSDN通过智能技术生成

使用Quartz做计划任务时,默认情况下,当前任务总会执行,无论前一个任务是否结束。

使用Spring配置Quartz的Job的时候,也是默认当前任务总会执行,无论前一个任务是否结束。

因此,如果采用默认条件,需要考虑并发执行的逻辑问题,否则需要设置为顺序执行。

我写了一个Spring配置Quartz的Demo。里面Spring的xml中

代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:jms="http://www.springframework.org/schema/jms" xmlns:lang="http://www.springframework.org/schema/lang"
	xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:oxm="http://www.springframework.org/schema/oxm"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:sec="http://www.springframework.org/schema/security"
	xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"

	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
		http://www.springframework.org/schema/aop http://www.springframewo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值