Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict queries fired by quartz-scheduler

I have the Quartz scheduler with Spring as part of my application, which is deployed in a clustered environment. The problem is that Quartz keeps firing a lot of queries (hundreds per minute) even though my jobs are scheduled to run once per hour (the jobs are triggered correctly). Is there a way to avoid/delay these Quartz queries?

EDIT: adding some queries fired by Quartz

UPDATE QRTZ_TRIGGERS SET TRIGGER_STATE = 'ACQUIRED' WHERE SCHED_NAME = 'SW_QUARTZ_SCHEDULER' AND TRIGGER_NAME = 'createCronTriggerFactoryBeanForPSDJob' AND TRIGGER_GROUP = 'SPRING3-QUARTZ' AND TRIGGER_STATE = 'WAITING'

INSERT INTO QRTZ_FIRED_TRIGGERS (SCHED_NAME, ENTRY_ID, TRIGGER_NAME, TRIGGER_GROUP, INSTANCE_NAME, FIRED_TIME, STATE, JOB_NAME, JOB_GROUP, IS_NONCONCURRENT, REQUESTS_RECOVERY, PRIORITY) VALUES('SW_QUARTZ_SCHEDULER', 'sw-jayz-5413692078375651369207837517', 'createCronTriggerFactoryBeanForPSDJob', 'SPRING3-QUARTZ', 'sw-jayz-541369207837565', 1369207800000, 'ACQUIRED', NULL, NULL, 0, 0, 0)

SELECT * FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'SW_QUARTZ_SCHEDULER' AND JOB_NAME = 'createJobDetailFactoryBeanForPSDJob' AND JOB_GROUP = 'SPRING3-QUARTZ
DELETE FROM QRTZ_SIMPLE_TRIGGERS WHERE SCHED_NAME = 'SW_QUARTZ_SCHEDULER' AND TRIGGER_NAME = 'createCronTriggerFactoryBeanForQMRJob' AND TRIGGER_GROUP = 'SPRING3-QUARTZ'
like image 743
Jayz Avatar asked May 22 '13 08:05

Jayz


People also ask

How do you stop a Quartz job?

deleteJob(jobKey(<JobKey>, <JobGroup>)); This method will only interrupt/stop the job uniquely identified by the Job Key and Group within the scheduler which may have many other jobs running. scheduler. shutdown();

How many jobs can Quartz handle?

The actual number of jobs that can be running at any moment in time is limited by the size of the thread pool. If there are five threads in the pool, no more than five jobs can run at a time.

How do you pause quartz scheduler in Java?

Pause the JobDetail with the given name - by pausing all of its current Trigger s. Pause all of the JobDetail s in the matching groups - by pausing all of their Trigger s. Pause the Trigger with the given name.

How do you turn off a quartz scheduler?

To shutdown / destroy a scheduler, simply call one of the shutdown(..) methods. Once you have shutdown a scheduler, it cannot be restarted (as threads and other resources are permanently destroyed). Also see the suspend method if you wish to simply pause the scheduler for a while.


1 Answers

I think you're looking for org.quartz.scheduler.idleWaitTime, which defaults to hitting the database every 30 seconds to look for new queries when the schedule has nothing better to do. (Documentation link)

like image 56
Nathaniel Waisbrot Avatar answered Oct 28 '22 13:10

Nathaniel Waisbrot