开发者

How to create a custom Quartz trigger?

开发者 https://www.devze.com 2023-02-11 12:27 出处:网络
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 belo

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

  1. Time is past 5 PM
  2. 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
0

精彩评论

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