satya
satya

Reputation: 81

how to remove unused triggers from quartz tables

I'm using spring with Quartz and every thing is working fine but some previously cofigured triggers also got executed because they are stored in Quartz tables. Manually we can delete all unconfigured triggers and execute the application but that is not a good practice. I want to remove all the triggers through a spring+quartz property or some other solution.

When I have configured 3 triggers in spring configuration file like

<property name="triggers">
    <list>
        <ref bean="FirstTrigger" />
        <ref bean="secondTrigger" />
        <ref bean="ThirdTrigger"/>
    </list>
</property>

When server started, all the triggers stored in Quartz tables with corresponding cron triggers and job details. If i remove any of the triggers in my configuration, in above for example I removed second Trigger, but it wasn't removed from Quartz tables. At that time DBtrigger (removed trigger) also executed.

In spring + Quartz integration, is there any property to handle this problem or do we need to do something else for this problem?

Thanks in advance.

Upvotes: 8

Views: 23721

Answers (2)

gaborsch
gaborsch

Reputation: 15758

You can access the Quartz Scheduler, Jobs, Triggers, etc. using the Quartz API.

Have a look at this Quartz CookBook, you will find out how to list all the triggers defined, etc. Maybe you should remove the unnecessary triggers using this API.

Upvotes: 1

snowindy
snowindy

Reputation: 3251

If you store triggers in DB (suppose your triggers are cron-based), you can simply delete records like this:

DELETE FROM QRTZ_CRON_TRIGGERS WHERE SCHED_NAME='scheduler' and TRIGGER_NAME='myTrigger' and TRIGGER_GROUP='DEFAULT';
DELETE FROM QRTZ_TRIGGERS WHERE SCHED_NAME='scheduler' and TRIGGER_NAME='myTrigger' and TRIGGER_GROUP='DEFAULT';

You may also consider looking around other Quartz DB tables to find leftovers related to your job.

Upvotes: 7

Related Questions