码迷,mamicode.com
首页 > 编程语言 > 详细

spring定时器

时间:2016-12-27 22:42:41      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:cto   lin   cat   rri   void   XML   scheduled   处理   1.0   

applicationContext-timer.xml

<?xml version="1.0" encoding="GBK"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:esb="http://mule.mulesource.org/schema/esb"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://mule.mulesource.org/schema/esb http://mule.mulesource.org/schema/esb.xsd">

 

 

<bean id="waybillTimerTask" class="com.golden.ex.ts.timer.WaybillTimerTask" />
<bean id="scheduleWaybillTimerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="delay" value="60000" />
<property name="period" value="60000"/>
<property name="timerTask" ref="waybillTimerTask" />
</bean>

 

<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="scheduleWaybillTimerTask"/>
<ref bean="scheduleWaybillViewTimerTask" />
</list>
</property>
</bean>

 

 

 

 

WaybillTimerTask .java

@Override
public void run() {
try {
// 接单处理定时器
confirm();//方法名
} catch (Exception e) {
logger.error("接单处理定时器异常:" + e.getMessage());
}

try {
// 预约运单处理定时器
appoint();//方法名
} catch (Exception e) {
logger.error("预约运单处理定时器异常:" + e.getMessage());
}
}

 

spring定时器

标签:cto   lin   cat   rri   void   XML   scheduled   处理   1.0   

原文地址:http://www.cnblogs.com/susuhyc/p/5704166.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!