Aravind Yarram
Aravind Yarram

Reputation: 80176

How to create a custom Quartz trigger?

I searched google but couldn't find articles/tutorials on how to 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

Upvotes: 1

Views: 2712

Answers (2)

Tommi
Tommi

Reputation: 8608

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.

Upvotes: 3

sjr
sjr

Reputation: 9875

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

Upvotes: 0

Related Questions