美文网首页 Apache camel
【原创】camel Timer组件使用

【原创】camel Timer组件使用

作者: 技术100万 | 来源:发表于2018-12-02 00:41 被阅读0次

【原创】camel Timer组件,分析其源代码,是基于JDK java.util.Timer类的功能实现。

用于实现:定时执行业务任务。

URI 格式:

timer:[name]?[options]

options="time=xxx&pattern=xxxx&period=xxxx....................."

选项定义:

time:第一次执行的时间,与pattern同时使用。例如:2018-12-01 23:44:00,表示将在2018-12-01 23:44:00这个时间第一次开始执行。

pattern:自定义时间点格式,选项:yyyy-MM-dd HH:mm:ss, yyyy-MM-dd'T'HH:mm:ss,默认yyyy-MM-dd'T'HH:mm:ss

period:间隔执行时间,默认1000表示1秒执行一次,也可以定义60s等格式,为0时表示只执行一次。

delay:第一次执行延迟,例如:50000,将延迟5秒执行第一次,后面根据period执行。

fixedRate:是否间隔循环执行。默认为true,表示循环执行。

daemon:是否设置为守护线程,具体有什么特别的作用,暂时不清楚,欢迎同学评价这一点。

repeatCount:重复执行次数。

例如:

from("timer://foo?fixedRate=true&period=60000").to("bean:myBean?method=someMethodName");

表示60秒执行一次,循环执行。

源代码:可见camel-core-2.23.0.jar->org.apache.camel.component.timer.TimerComponent

相关文章

网友评论

    本文标题:【原创】camel Timer组件使用

    本文链接:https://www.haomeiwen.com/subject/sbpdcqtx.html