开发者

Can a cron trigger's timer be reset?

I know I can reset the Java timer, but, since I already have so much work done using only a cron trigger, I wonder if it's possible to reset the amount of time left before the trigger fires.

Here's a bit more detail:

  1. On the website, an event is chosen randomly from the database and plastered on the front page as the "Featured" event.
  2. Every three hours, the event is removed and the process is repeated with a new featured event.

So that's where the cron trigger comes in. Now, I want to add an additional rule:

If all the available spots for that event are taken, I want that event to fire prematurely, revolving right away with a new featured event and resuming the normal every-three-hours pattern. Otherwise, a sold out event just lingers on the front page as "featured".

Can this be done? I'm using Java SpringSource framework on tomcat 6.

Thank you.

Update: after continuing a few more google queries, I finally came up with the "reset()" function from http://spacemapper.sourceforge.net/mn8/api/org/media/mn8/util/cron/CronTrigger.html. But could this be implemented in Spring?

Here is some code, the timer isn't set to 3 hours currently, only for testing:

<bean id="queueJob" class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.---.-.service.scheduler.BaseQuartzScheduler" />
    <property name="jobDataAsMap">
        <map>
            <entry key="processorName" value="scheduleListingActions" />
            <entry key="methodName" value="revolveQueue" />
        </map>
    </prop开发者_JS百科erty> 
</bean>

<bean id="queueCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="queueJob" />
    <property name="cronExpression" value="1-59/59 * * * * ?" />
</bean>


You can use at (which lets you schedule when a program will be called) or just write a daemon that sleeps. Using cron for this purpose is messy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜