Spring 定时任务


<?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:context="http://www.springframework.org/schema/context"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd  
		 ">

	<!-- cron表达式:* * * * * *(共6位,使用空格隔开,具体如下) -->
	<!-- cron表达式:*(秒0-59) *(分钟0-59) *(小时0-23) *(日期1-31) *(月份1-12或是JAN-DEC) *(星期1-7或是SUN-SAT) -->
	<!-- 其中每个元素可以是一个值(如6),一个连续区间(9-12),一个间隔时间(8-18/4)(/表示每隔4小时),一个列表(1,3,5), -->
	<!-- 通配符。由于"月份中的日期"和"星期中的日期"这两个元素互斥的,必须要对其中一个设置?. -->

	<!-- 在子表达式(分钟)里的“0/15”表示从第0分钟开始,每15分钟 -->
	<!-- 0 0/5 14 * * ?" 在每天下午2点到下午2:55期间的每5分钟触发 -->
	<!-- "0 0 12 * * ?" 每天中午十二点触发 -->
	<!-- "0 15 10 ? * *" 每天早上10:15触发 -->
	<!-- "0 15 10 * * ?" 每天早上10:15触发 -->
	<!-- "0 * 14 * * ?" 每天从下午2点开始到2点59分每分钟一次触发 -->
	<!-- "0 0/5 14 * * ?" 每天从下午2点开始到2:55分结束每5分钟一次触发 -->
	<!-- "0 0/5 14,18 * * ?" 每天的下午2点至2:55和6点至6点55分两个时间段内每5分钟一次触发 -->
	<!-- "0 0-5 14 * * ?" 每天14:00至14:05每分钟一次触发 -->
	<!-- "0 10,44 14 ? 3 WED" 三月的每周三的14:10和14:44触发 -->
	<!-- "0 15 10 ? * MON-FRI" 每个周一、周二、周三、周四、周五的10:15触发 -->
		
	<bean name="pageVisitAcountTask" class="com.ffcs.wlan.task.PageVisitAcountTask"/>
	<bean name="logIntoOracleTask" class="com.ffcs.wlan.task.LogIntoOracleTask"/>
	<bean name="doubleCentreSyncTask" class="com.ffcs.wlan.task.DoubleCentreSyncTask"/>
	<bean name="updatPropertyTask" class="com.ffcs.wlan.task.UpdatPropertyTask"></bean>
	<bean name="checkOracleConnTask" class="com.ffcs.wlan.task.CheckOracleConnTask"/>
	
	<task:scheduler id="myScheduler" pool-size="10" />
	<task:scheduled-tasks scheduler="myScheduler">

		<!--检查oracle连通性-->
			<task:scheduled ref="checkOracleConnTask" method="check" cron="0/20 * * * * ?"/>
		
		<!-- 定时将日志 从redis中 同步到oracle 
  		<task:scheduled ref="logIntoOracleTask" method="insertPwdLogIntoOracle" cron="0/15 * * * * ?" />   
  		<task:scheduled ref="logIntoOracleTask" method="insertLoginLogIntoOracle" cron="0/30 * * * * ?" />   --> 
  		<task:scheduled ref="logIntoOracleTask" method="insertLogOutLogIntoOracle" cron="0/5 * * * * ?" />

		<!-- 双中心同步
   			<task:scheduled ref="doubleCentreSyncTask" method="syncToApplication" cron="0 0 1 * * ?" />    
  			<task:scheduled ref="doubleCentreSyncTask" method="syncToRemoteOracle" cron="0 0 1 * * ?" /> -->  
  			
		<!-- 每1min 将页面访问量 同步到oracle一次 
  			<task:scheduled ref="pageVisitAcountTask" method="sysPageVisitAccToDB" cron="0/30 * * * * ?" />  -->
  		
		<!--定期备份oracle到配置文件
  			<task:scheduled ref="updatPropertyTask" method="updatePropertyByReadOracle" cron="0 0 23 ? * MON" /> -->   

	</task:scheduled-tasks>


<!-- 环绕通知通知  日志入库前判断数据库连通性-->
		<bean id="connOracleTestAspect" class="com.ffcs.wlan.aop.ConnOracleTestAspect"/>
		<aop:config>
			<aop:aspect ref="connOracleTestAspect">
				<aop:pointcut id="logIntoOraclePointCut" expression="execution(* com.ffcs.wlan.task.LogIntoOracleTask.insert*(..))" />
				<aop:around method="doCheckConn" pointcut-ref="logIntoOraclePointCut"/>
			</aop:aspect>
		</aop:config> 

</beans>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值