看看DurationTrigger我写了一年前。
public class DurationTrigger implements Trigger {
/**
* <p> Create a trigger with the given period, start and end time that define a time window that a task will be
* scheduled within.</p>
*/
public DurationTrigger(Date startTime, Date endTime, long period) {...}
// ...
}
这里是你将如何安排这样的任务与此触发器:
Trigger trigger = new DurationTrigger(startTime, endTime, period);
ScheduledFuture task = taskScheduler.schedule(packageDeliveryTask, trigger);
或者,你可以使用CronTrigger/cron表达式:
<!-- Fire every minute starting at 2:00 PM and ending at 2:05 PM, every day -->
<task:scheduled-tasks>
<task:scheduled ref="simpleProcessor" method="process" cron="0 0-5 14 * * ?"/>
</task:scheduled-tasks>
看看这个JIRA为以及此弹簧整合article
编辑:
从JIRA的讨论,可以配置上面的DurationTrigger
,或与此有关的任何其他自定义触发,使用Spring集成:
<inbound-channel-adapter id="yourChannelAdapter"
channel="yourChannel">
<poller trigger="durationTrigger"/>
</inbound-channel-adapter>
<beans:bean id="durationTrigger" class="org.gitpod.scheduler.trigger.DurationTrigger">
<beans:constructor-arg value="${start.time}"/>
<beans:constructor-arg value="${end.time}"/>
<beans:constructor-arg value="${period}"/>
</beans:bean>
它是使用Spring集成在非常简单的项目,即使你不打算。您可以尽可能少地使用上述调度部分,或者像Spring Integration提供的许多其他企业集成模式一样。
你知道吗?正在搜索文档... – bacar