简体   繁体   中英

Java EE6 Schedule Range

I'm required to have a schedule that runs every 5 minutes from 10 am to 5:45pm, how do I do this with the @Schedule annotation?

So far, I'm limited to the @Schedule(hour=10-18;minute=*/5), but they insist I should have it until 5:45pm not 6pm.

As clearly stated in the documentation for @Schedule and @Schedules , you need to have two @Schedule annotations if you run two schedules - even if you don't like that fact.

Due to the cron-like limitations of having ranges only within individual elements (hours, minutes, seconds...), it's simply not posible to give that additional information of skipping the last two executions at *:50 and *:55 only at 5pm.

That said, you'd probably end up with something like

@Schedules({
   @Schedule(hour="10-16" minute="*/5"),
   @Schedule(hour="17" minute="0,5,10,15,20,25,30,35,40,45")
})

As you end up with schedule information into you sourcecode that way (even if it's in the form of an annotation) you could just as well run every five minutes and immediately return from the method if called after 5:49pm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM