Spring 整合quartz
来源:互联网 发布:股票基本面软件 编辑:程序博客网 时间:2024/06/05 05:04
记录一下现在新公司的牛b框架!
今日又模仿了经理的东西!又是不求甚解。
xxx-project-job.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:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"default-lazy-init="true"> <!-- 定时任务列表start --> <bean id="JobSchedules" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="recordTimeJobSchedule" /> <ref bean="taobaoMessageErrorHandleJobSchedule" /> <ref bean="cleanTempFolderJobSchedule" /> <ref bean="disabledProductAgentJobSchedule" /> </list> </property> </bean><!-- 定时任务列表end --><!-- 记录服务器运行时间任务start--><bean id="recordTimeJobSchedule" class="org.springframework.scheduling.quartz.CronTriggerBean"><property name="jobDetail"> <bean id="RemindJobScheduleInvoker" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="xxx_recordTimeJob"/> <property name="targetMethod"><value>perform</value></property> </bean> </property> <property name="cronExpression"> <value>0 1/5 * * * ?</value> </property></bean><!-- 记录服务器运行时间任务end--><!-- 淘宝消息处理错误重试任务 start--><bean id="taobaoMessageErrorHandleJobSchedule" class="org.springframework.scheduling.quartz.CronTriggerBean"><property name="jobDetail"> <bean id="TaobaoMessageErrorHandleJobScheduleInvoker" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="xxx_TaobaoMessageErrorHandleJob"/> <property name="targetMethod"><value>perform</value></property> </bean> </property> <property name="cronExpression"> <value>0 3/5 * * * ?</value> </property></bean><!-- 淘宝消息处理错误重试任务 end--><!-- 清理临时文件夹 start--><bean id="cleanTempFolderJobSchedule" class="org.springframework.scheduling.quartz.CronTriggerBean"><property name="jobDetail"> <bean id="CleanTempFolderJobScheduleInvoker" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="xxx_CleanTempFolderJob"/> <property name="targetMethod"><value>perform</value></property> </bean> </property> <property name="cronExpression"> <value>0 0 0 1 * ?</value> </property></bean><!-- 清理临时文件夹 end--><!-- 禁用产品 每天一点执行start --><bean id="disabledProductAgentJobSchedule" class="org.springframework.scheduling.quartz.CronTriggerBean"><property name="jobDetail"> <bean id="CleanTempFolderJobScheduleInvoker" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="xxx_productAgentDisabledJob"/> <property name="targetMethod"><value>perform</value></property> </bean> </property> <property name="cronExpression"> <value>0 0 1 * * ?</value> </property></bean><!-- 禁用产品 end--></beans>
执行的Service
package com.xxx.project.job;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import com.sanwn.framework.core.job.AbstractScheduleJob;import com.sanwn.distribution.basic.ApplicationService;import com.sanwn.distribution.business.service.TradeService;/** */@Service("xxx_CleanTempFolderJob")public class CleanTempFolderJob extends AbstractScheduleJob {private static Log logger = LogFactory.getLog(CleanTempFolderJob.class);@AutowiredApplicationService applicationService;public void run() {logger.debug("------清理临时文件夹 开始-----");applicationService.cleanTempFolder();logger.debug("------清理临时文件夹 完成-----");}}
<context:component-scan base-package="com.xxxx"/>
转一个quartz的表达式
点击打开链接
- Spring-----Spring整合Quartz
- spring整合quartz
- spring整合quartz
- spring整合quartz
- Spring整合quartz配置
- Spring 整合quartz
- Spring整合quartz
- Spring整合Quartz示例
- spring整合quartz
- spring quartz框架整合
- spring跟QuartZ整合
- Spring-quartz整合
- Quartz 整合Spring 小试牛刀
- spring整合quartz
- spring整合quartz
- Spring+Quartz整合
- Spring整合Quartz
- spring和quartz整合
- MyReport报表引擎2.7.6.0与MyReport.TD套打引擎1.0.5.0
- 谈谈linux的一些好处
- 动态规划-最大子串 HDOJ1003
- ClassLoader and 插件化设计
- 指针数组、数组指针、指向函数的指针
- Spring 整合quartz
- 在django里使用多个数据库
- AIX HA切换脚本问题总结
- 如何在Eclipse上通过插件获取github上的spring源码
- 贪心算法,递归算法,动态规划算法比较与总结
- Sprite Kit -- Sprite (3)
- NineOldAndroidsDemos 学习(4) FlakeView
- linux IPI
- CSharp调用Matlab编译的dll