Eqbal
Eqbal

Reputation: 4880

Grails unschedule a quartz job

I have a requirement to schedule and unschedule a quartz job programmatically. I was able to schedule it using MyJob.schedule(cronExpression). Is there a way to similarly unschedule the job?

I am using quartz plugin 0.4.2 with Grails 1.2.3

Upvotes: 4

Views: 3461

Answers (3)

ken
ken

Reputation: 666

Running version 1.0.1

See this http://jira.grails.org/browse/GPQUARTZ-132#comment-78800

The trigger name by default on the MyJob.schedule() is screwy hardceoded UUID "GRAILS_586eb149-83f7-486c-88fc-e44a5bb0541" & a static group value of "GRAILS_TRIGGERS"

Either A: lookup your triggerName by the cronvalue (assuming it's unique) B: don't use the simple MyJob.schedule( trig) simple coolness provided by grails plugin.

Upvotes: 0

Eqbal
Eqbal

Reputation: 4880

removeJob() removes the job altogether and it cannot be scheduled again programmatically with MyJob.schedule(Trigger)

Here is what worked for me,

quartzScheduler.unscheduleJob("TriggerName", "TriggerGroup")
//TriggerName and TriggerGroup are the name and group of the Trigger used for schedule

Upvotes: 6

Victor Sergienko
Victor Sergienko

Reputation: 13475

QuartzGrailsPlugin.groovy says it's removeJob().

Upvotes: 1

Related Questions