How to create a custom Quartz trigger?
I searched google but couldn't find articles/tutorials on how t开发者_StackOverflow中文版o create a custom trigger. Any pointers/suggestions are helpful. The custom trigger should wait until the below two conditions are met and then trigger a job
- Time is past 5 PM
- A record with particular value (say a column value for row id 10 is changed to "START") has arrived in a given table
I agree with sjr. I would just create a CronTrigger
with cronExpression 0 0/5 17-23 * * ?
(so it would fire every 5 minutes starting at 5 PM - adjust the frequency depending on your exact requirements) , and then check the database conditions upon job execution.
Disclaimer: I haven't used Quartz before, but looking at the javadoc Trigger
looks hard enough to implement. Can't you just run your job every minute or hour or whatever and put something like the following up the top:
if (!new org.joda.time.DateTime().getHourOfDay() >= 17 || !databaseRowIsInPlace()) {
return;
}
// Do complicated work
精彩评论