Quartz - Run Now
Quartz is an open source job scheduling system written in Java. Executing a job in quartz is based on the definition of triggers. But what if you are in a development environment where you don't want to schedule jobs and want to be able to run them on demand? The API of version 1.6.0 tells us that the triggerJob method in the Scheduler class can be used for that. Great! But the triggerJob method also seems to throw away your job from the scheduler. So the second time you run the job it's bingo!
A possible workaround we figured out for this is to reschedule the job with a simple trigger which will run immediatly:
new SimpleTrigger(jobName, groupName)
You could of course also use the rescheduleJob method but then you have to be sure the job is already scheduled. In our situation this was not the case.
Post a Comment
Comment now »