zoukankan      html  css  js  c++  java
  • spring定时器

    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());
    }
    }

  • 相关阅读:
    LOJ#10106. 「一本通 3.7 例 2」单词游戏
    小木棍(爆搜减枝)
    倍增求lca(模板)
    2018年第九届蓝桥杯C/C++A组省赛(最后一题)
    LOJ#10172. 「一本通 5.4 练习 1」涂抹果酱
    【[APIO/CTSC2007]动物园】状压DP
    c++滚动数组
    状态压缩入门(附经典题目和题解)
    小 M 的算式(dfs)
    P与NP问题详解
  • 原文地址:https://www.cnblogs.com/susuhyc/p/5704166.html
Copyright © 2011-2022 走看看