看看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