user2424607
user2424607

Reputation: 295

Quartz CronTrigger - How Can I Pause a Job and Resume It the Next Day

I have a job with a CronTrigger that is set to run once every minute, Monday through Friday: 0 0/1 * ? * MON-FRI. This job connects to a server and checks a SQL table. Once it finds a given number of rows in the table, it needs to stop checking the table for that day. How would I go about pausing the job after the rows are found and then resuming the job the next day?

The job would thus go something like this:

  1. Start checking the table every minute at the beginning of the day.

  2. Appropriate number of rows are found. Pause the job for the rest of the day.

  3. Resume the job at the beginning of the next day.

Upvotes: 0

Views: 1995

Answers (1)

jvilalta
jvilalta

Reputation: 6769

You could have the job schedule itself every time it runs. If there aren't enough rows, have the job schedule a one time trigger a minute in the future. If it finds enough rows, then have it schedule a trigger for the next day.

You could also do it by pausing and resuming the trigger but then you'll need another job to restart the paused trigger. There isn't a way to pause a trigger for a given amount of time.

Upvotes: 2

Related Questions