一,需要的依赖

<dependency><groupId>org.springframework.integration</groupId><artifactId>spring-integration-core</artifactId><version>4.1.6.RELEASE</version>
</dependency>

二,定时任务类

package demo.springintegration;
/*** 定时任务类* @author xiaohui**/
public class TimedTask {public String test() {System.out.println("hello world!");return "";}
}

三,配置文件

<?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:int="http://www.springframework.org/schema/integration"xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:task="http://www.springframework.org/schema/task"xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsdhttp://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsdhttp://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"><!-- 执行的次数(次数=capacity+1) --><int:channel id="count"><int:queue capacity="1000"/></int:channel><!-- 要执行的类 --><bean id="hello" class="demo.springintegration.TimedTask"/><!-- 指定要执行的类的方法及执行的次数 --><int:inbound-channel-adapter channel="count" ref="hello" method="test"><!-- 执行时间 --><!-- 每秒执行一次 --><int:poller cron="1 * * * * ? " /><!-- 秒(0~59)分钟(0~59)小时(0~23)天(月)(0~31,但是你需要考虑你月的天数)月(0~11)星期(1~7 1=SUN 或 SUN,MON,TUE,WED,THU,FRI,SAT)年份(1970-2099)特殊符号含义* :任意值,可以理解(每)? :只能在 天和星期中用。其中有一个必须为?(避免冲突)- :表示范围 如 1-10 如:* * * * ? 表示每分钟1-10秒每秒触发/ :从多少开始每隔多少 如: 0/1 * * * * ? 表示从0开始每秒触发, :表示指定的 如:2,4,6 * * * * ? 表示每分钟第2第4第6秒触发L :表示最后 只能在星期和月使用,如:在星期中使用5L表示最后一个星期四触发W :表示有效工作日(周一到周五),只能出现在月中,系统将在离指定日期的最近的有效工作日触发事件LW :这两个字符可以连用,表示在某个月最后一个工作日,即最后一个星期五。 # :用于确定每个月第几个星期几,只能出现在月中。例如在4#2,表示某月的第二个星期三。--></int:inbound-channel-adapter>
</beans>

四,cron表达式

如 * * * * * ? 2018 按顺序表示

秒(0~59)
分钟(0~59)
小时(0~23)
天(月)(0~31,但是你需要考虑你月的天数)
月(0~11)
星期(1~7 1=SUN 或 SUN,MON,TUE,WED,THU,FRI,SAT)
年份(1970-2099)(可)
            
特殊符号含义
* :任意值,可以理解(每)
? :只能在 天和星期中用。其中有一个必须为?(避免冲突)
- :表示范围 如 1-10 如:* * * * ? 表示每分钟1-10秒每秒触发
/ :从多少开始每隔多少 如: 0/1 * * * * ? 表示从0开始每秒触发
, :表示指定的 如:2,4,6 * * * * ? 表示每分钟第2第4第6秒触发
L :表示最后 只能在星期和月使用,如:在星期中使用5L表示最后一个星期四触发
W :表示有效工作日(周一到周五),只能出现在月中,系统将在离指定日期的最近的有效工作日触发事件
LW :这两个字符可以连用,表示在某个月最后一个工作日,即最后一个星期五。 
# :用于确定每个月第几个星期几,只能出现在月中。例如在4#2,表示某月的第二个星期三。

使用Spring Integration实现定时任务相关推荐

  1. #翻译NO.3# --- Spring Integration Framework

    为什么80%的码农都做不了架构师?>>>    2.4 Message Endpoints A Message Endpoint represents the "filte ...

  2. Spring Integration学习资料

    Spring Integration学习资料 1.1     背景 Spring框架的一个重要主题是控制反转.从广义上来说,Spring处理其上下文中管理的组件的职责.只要组件减轻了职责,它们同时也被 ...

  3. Spring Integration 4.3.10 发布,Spring 消息通信

    Spring Integration 4.3.10 发布了.Spring Integration 能在基于 Spring 的应用中进行简单的消息通信,并通过简单的适配器与外部系统集成.这些适配器提供了 ...

  4. #翻译NO.5# --- Spring Integration Framework

    为什么80%的码农都做不了架构师?>>>    本人觉得这一章很重要,那就是 Spring默认的channel 的实现 DirectChannel,这个要大家多按照原文理解,开发者为 ...

  5. spring怎么设置定时任务为每天凌晨2点执行和每小时执行一次?(亲测)

    每天凌晨2点  0 0 2 * * ?和每天隔一小时 0 * */1 * * ? 例1:每隔5秒执行一次:*/5 * * * * ? 例2:每隔5分执行一次:0 */5 * * * ? 在26分.29 ...

  6. ESB学习笔记(Spring Integration实战)

    http://wangleifire.iteye.com/blog/351749 介绍 Spring Integration是Spring公司的一套ESB框架. 前面ESB介绍中我也做了一定了解.我们 ...

  7. Spring+Quartz实现定时任务

    Spring整合Quartz实现定时任务步骤很简单,大致需要经过如下几步:创建任务(Job).配置JobDetail.配置触发器(Trigger).配置SchedulerFactoryBean 首先使 ...

  8. #翻译NO.4# --- Spring Integration Framework

    为什么80%的码农都做不了架构师?>>>    Part III. Core Messaging This section covers all aspects of the cor ...

  9. java中channelmessage,MessageStore支持的QueueChannel与Spring Integration Java Config

    Spring Integration reference guide指的是使用MessageStore实现为QueueChannel提供持久性. 提到了很多次,但是所有示例都使用XML配置,即 但是Q ...

最新文章

  1. RedHat.Enterprise.Linux.5.2 Yum源配置
  2. mssql sqlserver sql脚本自动遍历重复生成指定表记录
  3. Hibernate openSession() 和 getCurrentSession的区别 .
  4. boost::geometry::ring_type用法的测试程序
  5. 【RK3399Pro学习笔记】一、Thinker Edge R 安装系统和VNC服务
  6. MySQL8.0.22解压安装教程
  7. 计算日期在当月是第几周-【自然周(每月第一个周一为该月第一周)做法以及1号为第一周做法】
  8. 华为P7安装Linux,华为P7插卡步骤图解 华为P7电信/移动/联通版手机sim卡安装使用教程...
  9. 写函数,计算传入函数的字符串中,数字、字母、空格 以及 其他内容的个数,并返回结果
  10. 经典计算机模型,经典Volterra模型分界线的计算机模拟
  11. Pycharm问题:this applicatation failed to start because it could not find or laod the qt plaform plugin
  12. luogu P4881 hby与tkw的基情
  13. 1025.ws index.php.,程控电话交换机系统局数据和用户数据
  14. 干货|JustAuth三方账号授权登录免费搭建全流程
  15. 为什么oracle打不开,oracle-Ora-01081_数据库打不开_错误解决方法
  16. 穆利堂[推荐] WxPM信息化整体解决方案-河南郑州房地产工程项目管理系统软件 穆穆-movno1
  17. 海思SD3403开发板学习(五)
  18. 大力哥谈 DALI - DALI 电源调试和配置参数揭秘
  19. VUE2.0实现 高德地图 选择地点后 进行 行政区边界划分
  20. 订阅者java_发布者订阅者模式之JAVA实现

热门文章

  1. 【项目实战课】基于Pytorch的Semantic_Human_Matting(人像软分割)实战
  2. 删除指定文件夹以及文件下的文件
  3. mysql 添加字段 描述_mysql新建表 中是否自带描述字段?
  4. 自然语言处理(NLP)编程实战-1.2 使用朴素贝叶斯实现情感分类
  5. 2021年茶艺师(中级)考试总结及茶艺师(中级)复审模拟考试
  6. 自动补水排气定压机组工作原理
  7. ethercat通讯移植
  8. Android 实验二:Android MVC模式
  9. 水木清华BBS各版面进版画面留念
  10. javaFX学习之Menu下创建子菜单及菜单项的例子