Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cancel a scheduled Quartz job in Spring

I'm using Spring to inject a Quartz scheduler (abstracted with Spring's TaskScheduler interface) into my app that loads jobs configured from a database at startup.

It adds each job in the scheduler something like this:

TaskScheduler taskScheduler = ...;//injected    
Runnable runableThing = ...;
String cronExpression = ...; //from DB
taskScheduler.schedule(runableThing, new CronTrigger(cronExpression));

my question is this: Is it possible to specify something like a job_id that can subsequently be used to cancel the job/trigger - say in response to a user selecting the job to be cancelled in the web interface?

I've looked at the Spring docs and can't see a way to do this.

Any ideas gratefully received.

like image 269
Steve Neal Avatar asked Nov 24 '10 17:11

Steve Neal


1 Answers

Unscheduling a Particular Trigger of Job

scheduler.unscheduleJob(triggerName, triggerGroup);

Deleting a Job and Unscheduling All of Its Triggers

scheduler.deleteJob(jobName, jobGroup);

Ref: http://www.opensymphony.com/quartz/wikidocs/UnscheduleJob.html

like image 126
Puspendu Banerjee Avatar answered Sep 21 '22 14:09

Puspendu Banerjee